| 1 |
#!/bin/sh |
| 2 |
# autopkgtest check: Build and run a program with the help of musl-gcc |
| 3 |
# (C) 2013 Thomas Moulard |
| 4 |
# (C) 2014 Anton Gladky |
| 5 |
# Author: Thomas Moulard <[email protected]> |
| 6 |
# Anton Gladky <[email protected]> |
| 7 |
|
| 8 |
set -e |
| 9 |
|
| 10 |
WORKDIR=$(mktemp -d) |
| 11 |
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM |
| 12 |
cd $WORKDIR |
| 13 |
cat <<EOF > hello.c |
| 14 |
#include <stdio.h> |
| 15 |
int main(int argc, char **argv) |
| 16 |
{ |
| 17 |
printf("hello %d\n", argc); |
| 18 |
return 0; |
| 19 |
} |
| 20 |
EOF |
| 21 |
|
| 22 |
musl-gcc -static -Os -o hello hello.c |
| 23 |
echo "build (static): OK" |
| 24 |
[ -x hello ] |
| 25 |
file hello | grep "statically linked" |
| 26 |
./hello |
| 27 |
echo "run (static): OK" |
| 28 |
rm hello |
| 29 |
|
| 30 |
musl-gcc -fPIE -static-pie -Os -o hello hello.c |
| 31 |
echo "build (static-pie): OK" |
| 32 |
[ -x hello ] |
| 33 |
file hello | grep "static-pie linked" |
| 34 |
./hello |
| 35 |
echo "run (static-pie): OK" |
| 36 |
rm hello |
| 37 |
|
| 38 |
musl-gcc -Os -o hello hello.c |
| 39 |
echo "build (dynamic): OK" |
| 40 |
[ -x hello ] |
| 41 |
file hello | grep "dynamically linked" |
| 42 |
./hello |
| 43 |
echo "run (dynamic): OK" |
| 44 |
|
| 45 |
|
| 46 |
# test building with imported musl-fts |
| 47 |
cat <<EOF > fts.c |
| 48 |
#include <sys/types.h> |
| 49 |
#include <sys/stat.h> |
| 50 |
#include <fts.h> |
| 51 |
#include <stddef.h> |
| 52 |
int main(int argc, char **argv) |
| 53 |
{ |
| 54 |
char *path_argv[] = {"/", NULL}; |
| 55 |
FTS *fts = fts_open(path_argv, 0, NULL); |
| 56 |
fts_close(fts); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
EOF |
| 60 |
musl-gcc -Os -o fts fts.c |
| 61 |
echo "build (fts): OK" |
| 62 |
[ -x fts ] |
| 63 |
./fts |
| 64 |
echo "run (fts): OK" |