diff options
author | gleb <gleb@FreeBSD.org> | 2013-03-25 00:31:14 +0000 |
---|---|---|
committer | gleb <gleb@FreeBSD.org> | 2013-03-25 00:31:14 +0000 |
commit | 6fa7e98571a4ba3ef27bb02c1c5bdf9328da7333 (patch) | |
tree | e9fa302d11d1d8240b8af9d2d682fe2a9a04159c /tools/tools/shlib-compat/test | |
parent | e740fd1ca7e847599c7467d1112041207db09ec0 (diff) | |
download | FreeBSD-src-6fa7e98571a4ba3ef27bb02c1c5bdf9328da7333.zip FreeBSD-src-6fa7e98571a4ba3ef27bb02c1c5bdf9328da7333.tar.gz |
Add shlib-compat under tools.
shlib-compat is ABI compatibility checker for shared libraries with
symbol versioning.
Diffstat (limited to 'tools/tools/shlib-compat/test')
26 files changed, 527 insertions, 0 deletions
diff --git a/tools/tools/shlib-compat/test/Makefile b/tools/tools/shlib-compat/test/Makefile new file mode 100644 index 0000000..f4a3548 --- /dev/null +++ b/tools/tools/shlib-compat/test/Makefile @@ -0,0 +1,37 @@ +# $FreeBSD$ + +SUBDIR= libtest1 \ + libtest2 \ + libtest3 \ + libtestsys + +NUMTEST=3 + +.PHONY: test regress.sh gentests gendiffs cleandiffs + +test: all + sh regress.t + +prove: all + prove ${.CURDIR} + +regress.sh: + echo 'run() { ../shlib-compat.py --no-dump -vv libtest$$1/libtest$$1.so.0 libtest$$2/libtest$$2.so.0; }' > ${.TARGET} + N=`expr ${NUMTEST} \* ${NUMTEST}`; echo "echo 1..$$N" >> ${.TARGET} + echo 'REGRESSION_START($$1)' >> ${.TARGET} + for a in `jot ${NUMTEST}`; do for b in `jot ${NUMTEST}`; do echo "REGRESSION_TEST(\`$$a-$$b', \`run $$a $$b')"; done; done >> ${.TARGET} + echo "REGRESSION_END()" >> ${.TARGET} + + +gentests: regress.sh + for a in `jot ${NUMTEST}`; do for b in `jot ${NUMTEST}`; do ../shlib-compat.py -vv libtest$$a/libtest$$a.so.0 libtest$$b/libtest$$b.so.0 > regress.$$a-$$b.out; done; done + +gendiffs: + for a in `jot ${NUMTEST}`; do for b in `jot ${NUMTEST}`; do (diff -ur libtest$$a libtest$$b > regress.$$a-$$b.diff || exit 0); done; done + +cleandiffs: + rm -f regress.*-*.diff + +clean: cleandiffs + +.include <bsd.subdir.mk> diff --git a/tools/tools/shlib-compat/test/Makefile.inc b/tools/tools/shlib-compat/test/Makefile.inc new file mode 100644 index 0000000..14aaef6 --- /dev/null +++ b/tools/tools/shlib-compat/test/Makefile.inc @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= test${TESTNUM} +SHLIB_MAJOR= 0 + +SRCS+= test.c + +WARNS?= 3 + +DEBUG_FLAGS?= -g + +VERSION_DEF= ${.CURDIR}/../Versions.def +SYMBOL_MAPS= ${.CURDIR}/Symbol.map diff --git a/tools/tools/shlib-compat/test/Versions.def b/tools/tools/shlib-compat/test/Versions.def new file mode 100644 index 0000000..0f46445 --- /dev/null +++ b/tools/tools/shlib-compat/test/Versions.def @@ -0,0 +1,11 @@ +# $FreeBSD$ + +TEST_1.0 { +}; + +TEST_1.1 { +} TEST_1.0; + +TESTprivate_1.0 { +} TEST_1.1; + diff --git a/tools/tools/shlib-compat/test/libtest1/Makefile b/tools/tools/shlib-compat/test/libtest1/Makefile new file mode 100644 index 0000000..32d77d4 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest1/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +TESTNUM= 1 + +.include <../Makefile.inc> +.include <bsd.lib.mk> diff --git a/tools/tools/shlib-compat/test/libtest1/Symbol.map b/tools/tools/shlib-compat/test/libtest1/Symbol.map new file mode 100644 index 0000000..67649ae --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest1/Symbol.map @@ -0,0 +1,12 @@ +/* + * $FreeBSD$ + */ + +TEST_1.0 { + func1; + func2; + func3; + func4; + func5; + func6; +}; diff --git a/tools/tools/shlib-compat/test/libtest1/test.c b/tools/tools/shlib-compat/test/libtest1/test.c new file mode 100644 index 0000000..dc3a561 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest1/test.c @@ -0,0 +1,66 @@ +/* + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <sys/stdint.h> + +struct s1 { + int32_t f1_int; + char *f2_str; + short f3_short; + uint64_t f4_uint64; + intmax_t f5_intmax; + void* f6_ptr; +}; + +struct s2 { + char f1_buf[30]; + struct s1 *f2_s1; +}; + +struct s3 { + struct s1 f1_s1; + uint32_t f2_int32; +}; + +int func1(int a, int b); +int func2(int64_t a, uint64_t b); +void func3(struct s1 *s); +void func4(struct s1 s); +int func5(int a, void *b, struct s2 *s); +int func6(char a, struct s3 *s); + +int +func1(int a, int b) +{ + return (a - b); +} + +int +func2(int64_t a, uint64_t b) +{ + return (a - b); +} + +void +func3(struct s1 *s) +{ +} + +void +func4(struct s1 s) +{ +} + +int +func5(int a, void *b, struct s2 *s) +{ + return (0); +} + +int +func6(char a, struct s3 *s) +{ + return (0); +} diff --git a/tools/tools/shlib-compat/test/libtest2/Makefile b/tools/tools/shlib-compat/test/libtest2/Makefile new file mode 100644 index 0000000..f1c277d --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest2/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +TESTNUM= 2 + +.include <../Makefile.inc> +.include <bsd.lib.mk> diff --git a/tools/tools/shlib-compat/test/libtest2/Symbol.map b/tools/tools/shlib-compat/test/libtest2/Symbol.map new file mode 100644 index 0000000..d4b7826 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest2/Symbol.map @@ -0,0 +1,15 @@ +/* + * $FreeBSD$ + */ + +TEST_1.0 { + func2; + func3; + func4; + func5; + func6; +}; + +TEST_1.1 { + func1; +}; diff --git a/tools/tools/shlib-compat/test/libtest2/test.c b/tools/tools/shlib-compat/test/libtest2/test.c new file mode 100644 index 0000000..c26935c --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest2/test.c @@ -0,0 +1,74 @@ +/* + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <sys/stdint.h> + +struct s1 { + int32_t f1_int; + char *f2_str; + short f3_short; + uint64_t f4_uint64; + intmax_t f5_intmax; + void* f6_ptr; +}; + +struct s2 { + char f1_buf[30]; + struct s1 *f2_s1; +}; + +struct s3 { + struct s1 f1_s1; + uint32_t f2_int32; +}; + +int func1(uint64_t a, uint64_t b); +int compat_func1(int a, int b); +int func2(int64_t a, uint64_t b); +void func3(struct s1 *s); +void func4(struct s1 s); +int func5(int a, void *b, struct s2 *s); +int func6(char a, struct s3 *s); + +int +func1(uint64_t a, uint64_t b) +{ + return (a - b); +} + +int +compat_func1(int a, int b) +{ + return func1(a, b); +} +__sym_compat(func1, compat_func1, TEST_1.0); + +int +func2(int64_t a, uint64_t b) +{ + return (a - b); +} + +void +func3(struct s1 *s) +{ +} + +void +func4(struct s1 s) +{ +} + +int +func5(int a, void *b, struct s2 *s) +{ + return (0); +} + +int +func6(char a, struct s3 *s) +{ + return (0); +} diff --git a/tools/tools/shlib-compat/test/libtest3/Makefile b/tools/tools/shlib-compat/test/libtest3/Makefile new file mode 100644 index 0000000..9f8970f --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest3/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +TESTNUM= 3 + +.include <../Makefile.inc> +.include <bsd.lib.mk> diff --git a/tools/tools/shlib-compat/test/libtest3/Symbol.map b/tools/tools/shlib-compat/test/libtest3/Symbol.map new file mode 100644 index 0000000..67649ae --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest3/Symbol.map @@ -0,0 +1,12 @@ +/* + * $FreeBSD$ + */ + +TEST_1.0 { + func1; + func2; + func3; + func4; + func5; + func6; +}; diff --git a/tools/tools/shlib-compat/test/libtest3/test.c b/tools/tools/shlib-compat/test/libtest3/test.c new file mode 100644 index 0000000..95a169c6 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtest3/test.c @@ -0,0 +1,87 @@ +/* + * $FreeBSD$ + */ + +#include <sys/types.h> +#include <sys/stdint.h> + +struct s1 { + int f1_int; + char *f2_str; + short f3_short; + uint64_t f4_uint64; + intmax_t f5_intmax; + void* f6_ptr; +}; + +struct s2 { + char f1_buf[20]; + struct s1 *f2_s1; +}; + +struct s3 { + struct s1 f1_s1; + uint32_t f2_int32; +}; + +enum f3_t { + f3_val0, f3_val1 +}; + +struct s4 { + struct s1 f1_s1; + uint32_t f2_int32; + enum f3_t f3_enum; +}; + +typedef int i32; + +int func1(int a, int b); +int func2(int64_t a, uint64_t b); +void func3(struct s1 *s); +void func4(struct s1 s); +int32_t func5(i32 a, void *b, struct s2 *s); +int func6__compat(char a, struct s3 *s); +int func6(char a, struct s4 *s); + +int +func1(int a, int b) +{ + return (a - b); +} + +int +func2(int64_t a, uint64_t b) +{ + return (a - b); +} + +void +func3(struct s1 *s) +{ +} + +void +func4(struct s1 s) +{ +} + +int +func5(int a, void *b, struct s2 *s) +{ + return (0); +} + +int +func6(char a, struct s4 *s) +{ + return (0); +} + +int +func6__compat(char a, struct s3 *s) +{ + return (0); +} + +__sym_compat(func6, func6__compat, TEST_1.0); diff --git a/tools/tools/shlib-compat/test/libtestsys/Makefile b/tools/tools/shlib-compat/test/libtestsys/Makefile new file mode 100644 index 0000000..837cfc3 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtestsys/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +TESTNUM= sys + +CLEANFILES+= test.c + +.include <../Makefile.inc> +.include <bsd.lib.mk> + +test.c: ../../makesyscalls-fake.sh + sh ${.CURDIR}/../../makesyscalls-fake.sh /usr/src/sys/kern/syscalls.master > ${.TARGET} diff --git a/tools/tools/shlib-compat/test/libtestsys/Symbol.map b/tools/tools/shlib-compat/test/libtestsys/Symbol.map new file mode 100644 index 0000000..d596923 --- /dev/null +++ b/tools/tools/shlib-compat/test/libtestsys/Symbol.map @@ -0,0 +1,9 @@ +/* + * $FreeBSD$ + */ + +TEST_1.0 { + mknod; + chmod; + stat; +}; diff --git a/tools/tools/shlib-compat/test/regress.1-1.out b/tools/tools/shlib-compat/test/regress.1-1.out new file mode 100644 index 0000000..5019980 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.1-1.out @@ -0,0 +1,8 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions match +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.1-2.out b/tools/tools/shlib-compat/test/regress.1-2.out new file mode 100644 index 0000000..981fa54 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.1-2.out @@ -0,0 +1,10 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0, TEST_1.1 +Added version: TEST_1.1 + Added symbols: func1@TEST_1.1 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions match +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.1-3.out b/tools/tools/shlib-compat/test/regress.1-3.out new file mode 100644 index 0000000..9844886 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.1-3.out @@ -0,0 +1,8 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions mismatch +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.2-1.out b/tools/tools/shlib-compat/test/regress.2-1.out new file mode 100644 index 0000000..9814778 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.2-1.out @@ -0,0 +1,10 @@ +Original versions: TEST_1.0, TEST_1.1 +New versions: TEST_1.0 +Removed version: TEST_1.1 + Removed symbols: func1@TEST_1.1 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions match +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.2-2.out b/tools/tools/shlib-compat/test/regress.2-2.out new file mode 100644 index 0000000..6d25425 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.2-2.out @@ -0,0 +1,9 @@ +Original versions: TEST_1.0, TEST_1.1 +New versions: TEST_1.0, TEST_1.1 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions match +func6@TEST_1.0: definitions match +func1@TEST_1.1: definitions match diff --git a/tools/tools/shlib-compat/test/regress.2-3.out b/tools/tools/shlib-compat/test/regress.2-3.out new file mode 100644 index 0000000..f278ca5 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.2-3.out @@ -0,0 +1,10 @@ +Original versions: TEST_1.0, TEST_1.1 +New versions: TEST_1.0 +Removed version: TEST_1.1 + Removed symbols: func1@TEST_1.1 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions mismatch +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.3-1.out b/tools/tools/shlib-compat/test/regress.3-1.out new file mode 100644 index 0000000..9844886 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.3-1.out @@ -0,0 +1,8 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions mismatch +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.3-2.out b/tools/tools/shlib-compat/test/regress.3-2.out new file mode 100644 index 0000000..f4ce323 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.3-2.out @@ -0,0 +1,10 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0, TEST_1.1 +Added version: TEST_1.1 + Added symbols: func1@TEST_1.1 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions mismatch +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.3-3.out b/tools/tools/shlib-compat/test/regress.3-3.out new file mode 100644 index 0000000..5019980 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.3-3.out @@ -0,0 +1,8 @@ +Original versions: TEST_1.0 +New versions: TEST_1.0 +func1@TEST_1.0: definitions match +func2@TEST_1.0: definitions match +func3@TEST_1.0: definitions match +func4@TEST_1.0: definitions match +func5@TEST_1.0: definitions match +func6@TEST_1.0: definitions match diff --git a/tools/tools/shlib-compat/test/regress.m4 b/tools/tools/shlib-compat/test/regress.m4 new file mode 100644 index 0000000..35e2ab9 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.m4 @@ -0,0 +1,59 @@ +# $FreeBSD$ + +dnl A library of routines for doing regression tests for userland utilities. + +dnl Start up. We initialise the exit status to 0 (no failure) and change +dnl into the directory specified by our first argument, which is the +dnl directory to run the tests inside. +define(`REGRESSION_START', +TESTDIR=$1 +if [ -z "$TESTDIR" ]; then + TESTDIR=. +fi +cd $TESTDIR + +STATUS=0) + +dnl Check $? to see if we passed or failed. The first parameter is the test +dnl which passed or failed. It may be nil. +define(`REGRESSION_PASSFAIL', +if [ $? -eq 0 ]; then + echo "ok - $1 # Test detected no regression. (in $TESTDIR)" +else + STATUS=$? + echo "not ok - $1 # Test failed: regression detected. See above. (in $TESTDIR)" +fi) + +dnl An actual test. The first parameter is the test name. The second is the +dnl command/commands to execute for the actual test. Their exit status is +dnl checked. It is assumed that the test will output to stdout, and that the +dnl output to be used to check for regression will be in regress.TESTNAME.out. +define(`REGRESSION_TEST', +$2 | diff -u regress.$1.out - +REGRESSION_PASSFAIL($1)) + +dnl A freeform regression test. Only exit status is checked. +define(`REGRESSION_TEST_FREEFORM', +$2 +REGRESSION_PASSFAIL($1)) + +dnl A regression test like REGRESSION_TEST, except only regress.out is used +dnl for checking output differences. The first argument is the command, the +dnl second argument (which may be empty) is the test name. +define(`REGRESSION_TEST_ONE', +$1 | diff -u regress.out - +REGRESSION_PASSFAIL($2)) + +dnl A fatal error. This will exit with the given status (first argument) and +dnl print the message (second argument) prefixed with the string "FATAL :" to +dnl the error stream. +define(`REGRESSION_FATAL', +echo "Bail out! $2 (in $TESTDIR)" > /dev/stderr +exit $1) + +dnl Cleanup. Exit with the status code of the last failure. Should probably +dnl be the number of failed tests, but hey presto, this is what it does. This +dnl could also clean up potential droppings, if some forms of regression tests +dnl end up using mktemp(1) or such. +define(`REGRESSION_END', +exit $STATUS) diff --git a/tools/tools/shlib-compat/test/regress.sh b/tools/tools/shlib-compat/test/regress.sh new file mode 100755 index 0000000..e113cce --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD$ + +run() { ../shlib-compat.py --no-dump -vv libtest$1/libtest$1.so.0.debug libtest$2/libtest$2.so.0.debug; } +echo 1..9 +REGRESSION_START($1) +REGRESSION_TEST(`1-1', `run 1 1') +REGRESSION_TEST(`1-2', `run 1 2') +REGRESSION_TEST(`1-3', `run 1 3') +REGRESSION_TEST(`2-1', `run 2 1') +REGRESSION_TEST(`2-2', `run 2 2') +REGRESSION_TEST(`2-3', `run 2 3') +REGRESSION_TEST(`3-1', `run 3 1') +REGRESSION_TEST(`3-2', `run 3 2') +REGRESSION_TEST(`3-3', `run 3 3') +REGRESSION_END() diff --git a/tools/tools/shlib-compat/test/regress.t b/tools/tools/shlib-compat/test/regress.t new file mode 100644 index 0000000..35feb20 --- /dev/null +++ b/tools/tools/shlib-compat/test/regress.t @@ -0,0 +1,6 @@ +#!/bin/sh +# $FreeBSD$ + +cd `dirname $0` + +m4 regress.m4 regress.sh | sh |