]>
Commit | Line | Data |
---|---|---|
558d2836 A |
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 | ||
927b7b56 A |
31 | for FS in JHFS+ APFS FAT32 EXFAT; do |
32 | touch "$DERIVED_SOURCES_DIR/$FS-dmg.dat" | |
33 | done | |
34 | ||
de8ee011 A |
35 | # The following change is taken directly from the XCBuild changes made for APFS in |
36 | # the commit cf61eef74b8 | |
37 | if [ "$CURRENT_ARCH" = undefined_arch ]; then | |
38 | # Xcode's New Build System, XCBuild, doesn't define CURRENT_ARCH anymore for script | |
39 | # targets. It does define ARCHS though, which is the complete list of architectures | |
40 | # being built for the platform. Since we don't really expect to have a different list | |
41 | # of tests for different architectures of the same platform, it should be safe to just | |
42 | # use the first one on the list for purposes of this script | |
43 | CURRENT_ARCH=${ARCHS%% *} | |
44 | fi | |
45 | ||
558d2836 A |
46 | # Look for any files containing the TEST macro. Then |
47 | # push those through the preprocessor (which should | |
48 | # filter out any that aren't applicable to the targeted | |
49 | # platform). Finally grep for the TEST macro again | |
50 | grep -l -E '^TEST\(' *.[cm] | xargs xcrun clang -E -D TEST=TEST \ | |
927b7b56 | 51 | -arch "$CURRENT_ARCH" -I"$DERIVED_SOURCES_DIR" -I.. -F"$SDKROOT""$SYSTEM_LIBRARY_DIR"/PrivateFrameworks | \ |
558d2836 A |
52 | grep -h -E 'TEST\(' >>"$DERIVED_FILE_DIR"/list-tests.c |
53 | ||
54 | # Build an executable for the host platform | |
4e640ade | 55 | env -i xcrun -sdk macosx.internal clang -x objective-c++ -I.. -c ../hfs-tests.mm \ |
558d2836 A |
56 | -o "$DERIVED_FILE_DIR"/hfs-tests.o -std=gnu++1y |
57 | ||
4e640ade | 58 | env -i xcrun -sdk macosx.internal clang -x objective-c -I.. -c ../disk-image.m \ |
558d2836 A |
59 | -o "$DERIVED_FILE_DIR"/disk-image.o |
60 | ||
4e640ade | 61 | env -i xcrun -sdk macosx.internal clang -x c -I.. -c ../systemx.c \ |
558d2836 A |
62 | -o "$DERIVED_FILE_DIR"/systemx.o |
63 | ||
4e640ade | 64 | env -i xcrun -sdk macosx.internal clang -x c -c "$DERIVED_FILE_DIR"/list-tests.c \ |
558d2836 A |
65 | -o "$DERIVED_FILE_DIR"/list-tests.o |
66 | ||
4e640ade | 67 | env -i xcrun -sdk macosx.internal clang++ "$DERIVED_FILE_DIR"/hfs-tests.o \ |
558d2836 A |
68 | "$DERIVED_FILE_DIR"/disk-image.o "$DERIVED_FILE_DIR"/list-tests.o \ |
69 | -o "$DERIVED_FILE_DIR"/list-tests "$DERIVED_FILE_DIR"/systemx.o \ | |
70 | -framework Foundation -lstdc++ | |
71 | ||
72 | # Now run the executable we just built to generate a plist | |
73 | mkdir -p "`basename \"$1\"`" | |
74 | ||
75 | "$DERIVED_FILE_DIR"/list-tests --plist list | plutil -convert binary1 - -o - >"$1" | |
76 | ||
77 | echo "Created $1" |