This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest-xz
executable file
·158 lines (133 loc) · 6.56 KB
/
test-xz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
set -e
resultsdir="$(pwd)/results"
xzurl='http://tukaani.org/xz/xz-5.2.2.tar.gz'
xzfile='xz-5.2.2.tar.gz'
localdir='xz-5.2.2'
JOBS=$(nproc||echo 1)
if [ ! -f "$xzfile" ]
then
echo -e "Downloading xz source files..."
curl -O "$xzurl"
else
echo -e "xz already downloaded. Continuing..."
fi
if [ ! -d "$localdir" ]
then
tar -xzvf "$xzfile"
else
echo -e "xz already extracted. Continuing..."
fi
cd "$localdir"
# download something to compress
if [ ! -f 'linux-4.6.tar.xz' ]
then
echo -e 'Downloading Linux source files...'
curl -O 'https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.6.tar.xz'
echo -e "Downloading Linux source files..."
else
echo -e "Linux already downloaded. Continuing..."
fi
if [ ! -f 'linux-4.6.tar' ]
then
echo -e 'Decompressing the Linux source...'
xz --decompress -k 'linux-4.6.tar.xz'
else
echo -e "Source files already decompressed. Continuing..."
fi
if [ -z "$1" ] || [ "1" == "$1" ]; then
echo -e 'Compiling with -fstack-protector-strong and partial relro'
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro' \
CFLAGS='-fstack-protector-strong -O2 -pipe' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 1"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test1-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test1-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 1 completed."
fi
if [ -z "$1" ] || [ "2" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, partial relro, and -fstack-check"
make clean
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fstack-check' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make -j${JOBS}
echo -e "Compilation finished, running test 2"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test2-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test2-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 2 completed."
fi
if [ -z "$1" ] || [ "3" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, partial relro, and PIE"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fPIE' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 3"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test3-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test3-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 3 completed."
fi
if [ -z "$1" ] || [ "4" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, partial relro, PIE, and -fstack-check"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fstack-check -fPIE' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 4"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test4-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test4-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 4 completed."
fi
if [ -z "$1" ] || [ "5" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, full relro, PIE"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fPIE' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 5"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test5-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test5-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 5 completed."
fi
if [ -z "$1" ] || [ "6" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, full relro, PIE, -fstack-check"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fPIE -fstack-check' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 6"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test6-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test6-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 6 completed."
fi
if [ -z "$1" ] || [ "7" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, full relro, PIE, -fno-plt"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fPIE -fno-plt' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 7"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test7-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test7-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 7 completed."
fi
if [ -z "$1" ] || [ "8" == "$1" ]; then
echo -e "Compiling with -fstack-protector-strong, full relro, PIE, -fno-plt, and -fstack-check"
LDFLAGS='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -pie' \
CFLAGS='-fstack-protector-strong -O2 -pipe -fPIE -fno-plt -fstack-check' \
CPPFLAGS='-D_FORTIFY_SOURCE=2' ./configure --disable-rpath --prefix=/usr
make clean
make -j${JOBS}
echo -e "Compilation finished, running test 8"
bash -c 'time src/xz/xz --compress --stdout linux-4.6.tar > /dev/null' |& tee "$resultsdir"/xz-test8-compress-`date +%Y-%m-%d.%H:%M:%S`
bash -c 'time src/xz/xz --decompress --stdout linux-4.6.tar.xz > /dev/null' |& tee "$resultsdir"/xz-test8-decompress-`date +%Y-%m-%d.%H:%M:%S`
echo -e "Test 8 completed."
fi