mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-17 15:41:35 +08:00
* Added some real tests.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
check_PROGRAMS = main
|
||||
check_PROGRAMS = main simple
|
||||
|
||||
TESTS = plain-run.sh $(XFAIL_TESTS)
|
||||
TESTS = plain-run.sh shrink.sh set-interpreter.sh $(XFAIL_TESTS)
|
||||
|
||||
XFAIL_TESTS = plain-fail.sh
|
||||
|
||||
|
||||
simple_SOURCES = simple.c
|
||||
|
||||
|
||||
main: main.o libfoo.so
|
||||
LD_LIBRARY_PATH=. $(CC) -o main main.o -L . -lfoo
|
||||
|
||||
@@ -12,7 +15,7 @@ main.o: main.c
|
||||
$(CC) -fpic -o main.o -c main.c
|
||||
|
||||
libfoo.so: foo.o libbar.so
|
||||
$(CC) -shared -o libfoo.so foo.o -L . -lbar
|
||||
$(CC) -shared -o libfoo.so foo.o -L . -lbar -Wl,-rpath,/no-such-path
|
||||
|
||||
foo.o: foo.c
|
||||
$(CC) -fpic -o foo.o -c foo.c
|
||||
|
22
tests/set-interpreter.sh
Executable file
22
tests/set-interpreter.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
./simple
|
||||
|
||||
oldInterpreter=$(../src/patchelf --print-interpreter ./simple)
|
||||
echo "current interpreter is $oldInterpreter"
|
||||
|
||||
rm -rf scratch
|
||||
mkdir -p scratch
|
||||
|
||||
cp simple scratch/
|
||||
../src/patchelf --interpreter $(pwd)/scratch/interpreter scratch/simple
|
||||
|
||||
echo "running with missing interpreter..."
|
||||
if scratch/simple; then
|
||||
echo "simple works, but it shouldn't"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "running with new interpreter..."
|
||||
ln -s "$oldInterpreter" scratch/interpreter
|
||||
scratch/simple
|
21
tests/shrink.sh
Executable file
21
tests/shrink.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#! /bin/sh -e
|
||||
|
||||
echo -n "RPATH before: "
|
||||
readelf -a ./libfoo.so | grep RPATH
|
||||
if ! readelf -a ./libfoo.so | grep RPATH | grep -q /no-such-path; then
|
||||
echo "incomplete RPATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf scratch
|
||||
mkdir -p scratch
|
||||
cp libfoo.so scratch/
|
||||
../src/patchelf --shrink-rpath scratch/libfoo.so
|
||||
|
||||
echo -n "RPATH after: "
|
||||
readelf -a scratch/libfoo.so | grep RPATH
|
||||
if readelf -a scratch/libfoo.so | grep RPATH | grep -q /no-such-path; then
|
||||
echo "incomplete RPATH"
|
||||
exit 1
|
||||
fi
|
||||
|
9
tests/simple.c
Normal file
9
tests/simple.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char buf[16 * 1024 * 1024];
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World\n");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user