Mercurial > crates > nonstick
annotate testharness/install-test-harness.sh @ 164:d0bba0117456
make test script more cross platform?
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Mon, 14 Jul 2025 18:12:14 -0400 |
| parents | a75a66cb4181 |
| children | c4b1e280463c |
| rev | line source |
|---|---|
|
164
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
1 #!/bin/sh |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
2 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
3 set -exo pipefail |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
4 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
5 LINUX_BSD_CONF="/etc/pam.d/nonstick-testharness" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
6 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
7 pam_library_path() { |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
8 case "$(uname -s)" in |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
9 "Linux" | "SunOS") |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
10 echo "/usr/lib/security" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
11 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
12 *BSD) |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
13 echo "/usr/lib" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
14 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
15 *) |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
16 echo "UNKNOWN OS!!!" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
17 return 1 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
18 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
19 esac |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
20 } |
|
163
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
21 |
|
164
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
22 setup_pam_conf() { |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
23 case "$(uname -s)" in |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
24 "Linux" | *BSD) |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
25 sudo cp nonstick_testharness.conf "$LINUX_BSD_CONF" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
26 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
27 "SunOS") |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
28 sudo cp /etc/pam.conf /etc/pam.conf.bak |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
29 sed 's/^\([^#]\)/nonstick-testharness \1/' <./nonstick_testharness.conf \ |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
30 | sudo tee -a /etc/pam.conf >/dev/null |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
31 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
32 *) |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
33 echo "UNKNOWN OS!!!" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
34 return 1 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
35 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
36 esac |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
37 } |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
38 cleanup_pam_conf() { |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
39 case "$(uname -s)" in |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
40 "Linux" | *BSD) |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
41 sudo rm "$LINUX_BSD_CONF" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
42 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
43 "SunOS") |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
44 sudo mv /etc/pam.conf.bak /etc/pam.conf |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
45 ;; |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
46 esac |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
47 } |
|
163
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
48 |
|
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
49 HERE="$(dirname -- "$0")" |
|
164
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
50 cd "$HERE" |
|
163
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
51 cargo build --release |
|
164
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
52 PAM_LIBRARY="$(pam_library_path)/pam_testharness.so" |
|
163
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
53 |
|
164
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
54 cleanup() { |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
55 sudo rm "$PAM_LIBRARY" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
56 cleanup_pam_conf |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
57 } |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
58 |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
59 sudo cp ../target/release/libnonstick_testharness.so "$PAM_LIBRARY" |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
60 setup_pam_conf |
|
d0bba0117456
make test script more cross platform?
Paul Fisher <paul@pfish.zone>
parents:
163
diff
changeset
|
61 trap cleanup EXIT |
|
163
a75a66cb4181
Add end-to-end tests; fix issues found by tests.
Paul Fisher <paul@pfish.zone>
parents:
diff
changeset
|
62 "$@" && echo "SUCCESS!!!" || echo "FAILURE: $?" |
