forked from cirosantilli/linux-kernel-module-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-build-userland
executable file
·70 lines (60 loc) · 1.97 KB
/
test-build-userland
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
#!/usr/bin/env bash
# https://cirosantilli.com/linux-kernel-module-cheat#cli-script-tests
set -eux
for in_tree in '' --in-tree; do
userland_build_dir="$(./getvar $in_tree userland_build_dir)"
# Toplevel.
./build-userland $in_tree
[ -f "${userland_build_dir}/c/hello.out" ]
./build-userland $in_tree --clean
! [ -f "${userland_build_dir}/c/hello.out" ]
# Toplevel explicit.
./build-userland $in_tree userland/
[ -f "${userland_build_dir}/c/hello.out" ]
./build-userland $in_tree --clean
! [ -f "${userland_build_dir}/c/hello.out" ]
# Toplevel root dir.
./build-userland $in_tree .
[ -f "${userland_build_dir}/c/hello.out" ]
./build-userland $in_tree --clean
! [ -f "${userland_build_dir}/c/hello.out" ]
# Subdirectory.
./build-userland $in_tree userland/c
[ -f "${userland_build_dir}/c/hello.out" ]
./build-userland $in_tree --clean userland/c
! [ -f "${userland_build_dir}/c/hello.out" ]
# One program.
./build-userland $in_tree userland/c/hello.c
[ -f "${userland_build_dir}/c/hello.out" ]
./build-userland $in_tree --clean userland/c/hello.c
! [ -f "${userland_build_dir}/c/hello.out" ]
# Things that don't work: building:
# - non-existent files
# - paths outside of tree
! ./build-userland $in_tree userland/c/hello
! ./build-userland $in_tree userland/c/hello.
! ./build-userland $in_tree "${userland_build_dir}/c/hello.out"
tmpfile="$(mktemp)"
! ./build-userland $in_tree "$tmpfile"
! ./build-userland --clean $in_tree "$tmpfile"
rm "$tmpfile"
! ./build-userland $in_tree ..
! ./build-userland $in_tree kernel_modules
! ./build-userland --clean $in_tree userland/does_not_exist
./build-userland --clean $in_tree
done
./build-userland-in-tree
[ -f userland/c/hello.out ]
./build-userland-in-tree --clean
! [ -f userland/c/hello.out ]
cd userland
./build
[ -f c/hello.out ]
./build --clean
! [ -f c/hello.out ]
./build c
[ -f c/hello.out ]
./build --clean c
! [ -f c/hello.out ]
./build --clean c/hello.c
! [ -f c/hello.out ]