Skip to content

Commit b2fc6ad

Browse files
author
Shuah Khan
committed
selftests: sync: kselftest and kselftest-clean fail for make O=dir case
sync test fails to build when object directory is specified to relocate object files. Fix it to specify the correct path. Fix clean target to remove objects. Also include simplified logic to use TEST_CUSTOM_PROGS in build and clean targets instead of hard-coding the test name each time. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
1 parent 38f7251 commit b2fc6ad

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎tools/testing/selftests/sync/Makefile‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
22
CFLAGS += -I../../../../usr/include/
33
LDFLAGS += -pthread
44

5-
# lib.mk TEST_CUSTOM_PROGS var is for custome tests that need special
5+
.PHONY: all clean
6+
7+
include ../lib.mk
8+
9+
# lib.mk TEST_CUSTOM_PROGS var is for custom tests that need special
610
# build rules. lib.mk will run and install them.
7-
TEST_CUSTOM_PROGS = sync_test
811

12+
TEST_CUSTOM_PROGS := $(OUTPUT)/sync_test
913
all: $(TEST_CUSTOM_PROGS)
1014

11-
include ../lib.mk
12-
1315
OBJS = sync_test.o sync.o
1416

1517
TESTS += sync_alloc.o
@@ -20,6 +22,16 @@ TESTS += sync_stress_parallelism.o
2022
TESTS += sync_stress_consumer.o
2123
TESTS += sync_stress_merge.o
2224

23-
sync_test: $(OBJS) $(TESTS)
25+
OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
26+
TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
27+
28+
$(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
29+
$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)
30+
31+
$(OBJS): $(OUTPUT)/%.o: %.c
32+
$(CC) -c $^ -o $@
33+
34+
$(TESTS): $(OUTPUT)/%.o: %.c
35+
$(CC) -c $^ -o $@
2436

25-
EXTRA_CLEAN := sync_test $(OBJS) $(TESTS)
37+
EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)

0 commit comments

Comments
 (0)