]> git.saurik.com Git - apple/hfs.git/blob - tests/gen-test-plist.sh
hfs-366.70.1.tar.gz
[apple/hfs.git] / tests / gen-test-plist.sh
1 #!/bin/bash
2
3 # gen-test-plist.sh
4 # hfs
5 #
6 # Created by Chris Suter on 8/13/15.
7 #
8
9 #set -x
10
11 if [ ! "$1" ] ; then
12 echo "usage: gen-test-plist.sh <target-plist>"
13 exit 1
14 fi
15
16 cd "$SRCROOT"/tests/cases
17
18 mkdir -p "$DERIVED_FILE_DIR"
19
20 cat >"$DERIVED_FILE_DIR"/list-tests.c <<EOF
21 #include "$SRCROOT/tests/hfs-tests.h"
22 #undef TEST
23 #define TEST(x, ...) \
24 TEST_DECL(x, ## __VA_ARGS__) \
25 static int run_##x(__unused test_ctx_t *ctx) { return 1; }
26 EOF
27
28 set -e
29 set -o pipefail
30
31 # Look for any files containing the TEST macro. Then
32 # push those through the preprocessor (which should
33 # filter out any that aren't applicable to the targeted
34 # platform). Finally grep for the TEST macro again
35 grep -l -E '^TEST\(' *.[cm] | xargs xcrun clang -E -D TEST=TEST \
36 -arch "$CURRENT_ARCH" -I.. -F"$SDKROOT""$SYSTEM_LIBRARY_DIR"/PrivateFrameworks | \
37 grep -h -E 'TEST\(' >>"$DERIVED_FILE_DIR"/list-tests.c
38
39 # Build an executable for the host platform
40 env -i xcrun clang -x objective-c++ -I.. -c ../hfs-tests.mm \
41 -o "$DERIVED_FILE_DIR"/hfs-tests.o -std=gnu++1y
42
43 env -i xcrun clang -x objective-c -I.. -c ../disk-image.m \
44 -o "$DERIVED_FILE_DIR"/disk-image.o
45
46 env -i xcrun clang -x c -I.. -c ../systemx.c \
47 -o "$DERIVED_FILE_DIR"/systemx.o
48
49 env -i xcrun clang -x c -c "$DERIVED_FILE_DIR"/list-tests.c \
50 -o "$DERIVED_FILE_DIR"/list-tests.o
51
52 env -i xcrun clang++ "$DERIVED_FILE_DIR"/hfs-tests.o \
53 "$DERIVED_FILE_DIR"/disk-image.o "$DERIVED_FILE_DIR"/list-tests.o \
54 -o "$DERIVED_FILE_DIR"/list-tests "$DERIVED_FILE_DIR"/systemx.o \
55 -framework Foundation -lstdc++
56
57 # Now run the executable we just built to generate a plist
58 mkdir -p "`basename \"$1\"`"
59
60 "$DERIVED_FILE_DIR"/list-tests --plist list | plutil -convert binary1 - -o - >"$1"
61
62 echo "Created $1"