summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-03-01 15:06:22 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2021-03-01 15:06:22 -0500
commit7e62881c8f6c1fb45b83037bedfc8fb5fae380cd (patch)
tree77bf5a7d8190de2dd5d390f15579f8ca5f606f31 /test
parent0e6b1b24603948dab13f165f03a75e357e44d518 (diff)
downloadlibfaketime-7e62881c8f6c1fb45b83037bedfc8fb5fae380cd.tar.gz
Name "snippets" explicitly
Earlier, this code was conceived of to test a "function" specifically, but some future snippet could test multiple function calls, or a subset of a function call (e.g. snippets/syscall_clock_gettime.c already only tests one particular syscall diversion number). Normalizing on the name "snippet" should make it easier to understand the code going forward.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile14
-rw-r--r--test/_libtest.c8
-rw-r--r--test/_run_test.c2
-rw-r--r--test/_use_lib_test.c6
4 files changed, 15 insertions, 15 deletions
diff --git a/test/Makefile b/test/Makefile
index fc663c2..e0086be 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,7 +6,7 @@ LDFLAGS = -lrt -lpthread
SRC = timetest.c
OBJ = ${SRC:.c=.o}
-TESTFUNCS = $(notdir $(basename $(wildcard snippets/*.c)))
+TEST_SNIPPETS = $(notdir $(basename $(wildcard snippets/*.c)))
EXPECTATIONS= $(notdir $(basename $(wildcard snippets/*.variable)))
all: timetest test
@@ -37,24 +37,24 @@ test_variable_data: test_variable_data.sh $(foreach f,${EXPECTATIONS},run_${f})
./test_variable_data.sh ${EXPECTATIONS}
run_%: _run_test.c snippets/%.c
- sed s/FUNC_NAME/$*/g < _run_test.c | ${CC} -o $@ ${CFLAGS} -x c -
+ sed s/SNIPPET_NAME/$*/g < _run_test.c | ${CC} -o $@ ${CFLAGS} -x c -
## testing when interception points get called in library constructors:
-test_library_constructors: test_constructors.sh $(foreach f,${TESTFUNCS},use_lib_${f} lib${f}.so)
- true $(foreach f,${TESTFUNCS},&& ./test_constructors.sh ${f})
+test_library_constructors: test_constructors.sh $(foreach f,${TEST_SNIPPETS},use_lib_${f} lib${f}.so)
+ true $(foreach f,${TEST_SNIPPETS},&& ./test_constructors.sh ${f})
lib%.so: _libtest.c snippets/%.c
- sed s/FUNC_NAME/$*/g < _libtest.c | ${CC} -shared -o $@ -fpic ${CFLAGS} -x c -
+ sed s/SNIPPET_NAME/$*/g < _libtest.c | ${CC} -shared -o $@ -fpic ${CFLAGS} -x c -
use_lib_%: _use_lib_test.c snippets/%.c lib%.so
- sed s/FUNC_NAME/$*/g < _use_lib_test.c | ${CC} -L. -o $@ ${CFLAGS} -x c - -l$*
+ sed s/SNIPPET_NAME/$*/g < _use_lib_test.c | ${CC} -L. -o $@ ${CFLAGS} -x c - -l$*
## cleanup and metainformation
clean:
- @rm -f ${OBJ} timetest getrandom_test syscall_test $(foreach f,${TESTFUNCS},use_lib_${f} lib${f}.so run_${f})
+ @rm -f ${OBJ} timetest getrandom_test syscall_test $(foreach f,${TEST_SNIPPETS},use_lib_${f} lib${f}.so run_${f})
distclean: clean
@echo
diff --git a/test/_libtest.c b/test/_libtest.c
index 2fa0bc9..886e313 100644
--- a/test/_libtest.c
+++ b/test/_libtest.c
@@ -1,8 +1,8 @@
#include "snippets/include_headers.h"
#define where "library"
-void FUNC_NAME_as_needed() {
- printf(" called FUNC_NAME_as_needed() \n");
+void SNIPPET_NAME_as_needed() {
+ printf(" called SNIPPET_NAME_as_needed() \n");
}
-static __attribute__((constructor)) void init_FUNC_NAME() {
-#include "snippets/FUNC_NAME.c"
+static __attribute__((constructor)) void init_SNIPPET_NAME() {
+#include "snippets/SNIPPET_NAME.c"
}
diff --git a/test/_run_test.c b/test/_run_test.c
index 63672f9..7cbaffb 100644
--- a/test/_run_test.c
+++ b/test/_run_test.c
@@ -1,5 +1,5 @@
#include "snippets/include_headers.h"
#define where "direct"
int main() {
-#include "snippets/FUNC_NAME.c"
+#include "snippets/SNIPPET_NAME.c"
}
diff --git a/test/_use_lib_test.c b/test/_use_lib_test.c
index 24d8cc7..5a21d17 100644
--- a/test/_use_lib_test.c
+++ b/test/_use_lib_test.c
@@ -1,7 +1,7 @@
#include "snippets/include_headers.h"
-extern void FUNC_NAME_as_needed();
+extern void SNIPPET_NAME_as_needed();
#define where "program"
int main() {
- FUNC_NAME_as_needed();
-#include "snippets/FUNC_NAME.c"
+ SNIPPET_NAME_as_needed();
+#include "snippets/SNIPPET_NAME.c"
}