From 574d990ef8536794e4a77c87c37631c3c0623f9f Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Thu, 18 Jun 2015 16:44:34 +0000 Subject: [PATCH] Remove dynamic test loading Unnecessary complexity Signed-off-by: Euan Harris --- Makefile | 13 ++++--------- async_test.c | 38 ++++---------------------------------- 2 files changed, 8 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index d5b87d8..0c5ada4 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,20 @@ SRCS = testcase_runner.c eventloop_runner.c testcase_utils.c async_test.c CFLAGS = -Wall -Wextra -Werror -pedantic -g -LDFLAGS = -Wl,-export-dynamic LDLIBS = -pthread -lxenctrl -lxlutil -lxenlight -ldl TESTS = $(wildcard test_*.c) ALL_SRCS = $(SRCS) $(TESTS) .PHONY: all -all: async_test $(TESTS:.c=.so) -async_test: $(SRCS:.c=.o) +all: $(TESTS:.c=) - -test_%.o: CFLAGS += -fPIC - -test_%.so: test_%.o - $(CC) -shared $< -o $@ +test_%: $(SRCS:.c=.o) test_%.o + $(CC) $(LDFLAGS) $(LDLIBS) $^ -o $@ %.d: %.c $(CC) -M $< > $@ .PHONY: clean clean: - rm -f $(ALL_SRCS:.c=.o) $(ALL_SRCS:.c=.d) $(TESTS:.c=.so) async_test + rm -f $(ALL_SRCS:.c=.o) $(ALL_SRCS:.c=.d) $(TESTS:.c=) -include $(ALL_SRCS:.c=.d) diff --git a/async_test.c b/async_test.c index c717187..5647536 100644 --- a/async_test.c +++ b/async_test.c @@ -5,42 +5,13 @@ #include "testcase_runner.h" #include "eventloop_runner.h" -int main(int argc, char **argv) +void *testcase(struct test *tc); + +int main(int argc __attribute__((unused)), + char **argv __attribute__((unused))) { struct test t; xentoollog_logger *logger; - char *test_path; - void *test_plugin; - void *(*testcase) (struct test *); - - if (argc != 2) { - fprintf(stderr, "Usage: %s \n", argv[0]); - exit(EXIT_FAILURE); - } - - /* dlopen only looks outside the standard library directories - if the path contains a slash. Resolve the real path to - the test file, to ensure that this is the case. */ - test_path = realpath(argv[1], NULL); - if (!test_path) { - perror(argv[1]); - exit(EXIT_FAILURE); - } - - test_plugin = dlopen(test_path, RTLD_NOW); - free(test_path); - if (!test_plugin) { - fprintf(stderr, "%s\n", dlerror()); - exit(EXIT_FAILURE); - } - dlerror(); - - *(void **)(&testcase) = dlsym(test_plugin, "testcase"); - if (!testcase) { - fprintf(stderr, "%s\n", dlerror()); - exit(EXIT_FAILURE); - } - dlerror(); logger = (xentoollog_logger *) xtl_createlogger_stdiostream(stderr, XTL_PROGRESS, 0); @@ -57,7 +28,6 @@ int main(int argc, char **argv) fprintf(stderr, "Test thread exited\n"); test_destroy(&t); xtl_logger_destroy(logger); - dlclose(test_plugin); exit(EXIT_SUCCESS); } -- 2.39.5