On Thu, 7 Jan 2021 10:32:08 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > Unit test must test the library located in the sorce tree, instead the > one installed in the system. I don't think this does what you want it to do. > > Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> > --- > utest/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/utest/Makefile b/utest/Makefile > index 403540a..6e9c760 100644 > --- a/utest/Makefile > +++ b/utest/Makefile > @@ -12,7 +12,7 @@ OBJS += tracefs-utest.o > > LIBS += -lcunit \ > -ldl \ > - -L$(obj)/lib/tracefs -ltracefs > + -L$(obj)/lib/tracefs -l:libtracefs.a > > OBJS := $(OBJS:%.o=$(bdir)/%.o) > DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) OK, I added to src/tracefs_events.c: void tracefs_hello(void) { printf("hello world!\n"); } And then to utest/trace-utest.c in main(): void tracefs_hello(void); tracefs_hello(); And try building. It caused this: /usr/bin/ld: /work/git/libtracefs.git/utest/trace-utest.o: in function `main': /work/git/libtracefs.git/utest/trace-utest.c:38: undefined reference to `tracefs_hello' collect2: error: ld returned 1 exit status That's because I have libtracefs.a installed as well as libtracefs.so, and it is using the system libtracefs.a and not the local one. But by making the following change: diff --git a/utest/Makefile b/utest/Makefile index 6e9c760..4899365 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -12,7 +12,7 @@ OBJS += tracefs-utest.o LIBS += -lcunit \ -ldl \ - -L$(obj)/lib/tracefs -l:libtracefs.a + $(obj)/lib/tracefs/libtracefs.a OBJS := $(OBJS:%.o=$(bdir)/%.o) DEPS := $(OBJS:$(bdir)/%.o=$(bdir)/.%.d) It builds. I just use the full path to the library, instead of using the linker option. -- Steve