Debian Codegraph @

launcher/image/test/scripts/test_launcher_workload.sh

raw
1 #!/bin/bash
2 set -euo pipefail
3 source util/read_serial.sh
4
5 # This test requires the workload to run and printing
6 # corresponding messages to the serial console.
7 SERIAL_OUTPUT=$(read_serial $1 $2)
8 print_serial=false
9
10 if echo $SERIAL_OUTPUT | grep -q 'Workload running'
11 then
12 echo "- workload running verified"
13 else
14 echo "FAILED: workload not running"
15 echo 'TEST FAILED.' > /workspace/status.txt
16 print_serial=true
17 fi
18
19 if echo $SERIAL_OUTPUT | grep -q 'Workload args: \[/main newCmd\]'
20 then
21 echo "- arguments verified"
22 else
23 echo "FAILED: arguments not verified"
24 echo 'TEST FAILED.' > /workspace/status.txt
25 print_serial=true
26 fi
27
28 if echo $SERIAL_OUTPUT | grep -q 'env_bar=val_bar'
29 then
30 echo "- env_bar env var verified"
31 else
32 echo "FAILED: env_bar env not verified"
33 echo 'TEST FAILED.' > /workspace/status.txt
34 print_serial=true
35 fi
36
37 if echo $SERIAL_OUTPUT | grep -q 'ALLOWED_OVERRIDE=overridden'
38 then
39 echo "- ALLOWED_OVERRIDE env var verified"
40 else
41 echo "FAILED: ALLOWED_OVERRIDE env not verified"
42 echo 'TEST FAILED.' > /workspace/status.txt
43 print_serial=true
44 fi
45
46 if echo $SERIAL_OUTPUT | grep -q 'aud: \[https://sts.googleapis.com\]'
47 then
48 echo "- token aud verified"
49 else
50 echo "FAILED: token aud not verified"
51 echo 'TEST FAILED.' > /workspace/status.txt
52 print_serial=true
53 fi
54
55 if echo $SERIAL_OUTPUT | grep -q 'iss: fake-issuer-for-testing'
56 then
57 echo "- token iss verified"
58 else
59 echo "FAILED: token iss not verified"
60 echo 'TEST FAILED.' > /workspace/status.txt
61 print_serial=true
62 fi
63
64 if echo $SERIAL_OUTPUT | grep -q 'secboot: true'
65 then
66 echo "- token secboot verified"
67 else
68 echo "FAILED: token secboot not verified"
69 echo 'TEST FAILED.' > /workspace/status.txt
70 print_serial=true
71 fi
72
73 if echo $SERIAL_OUTPUT | grep -q 'oemid: fake-oem-id'
74 then
75 echo "- token oemid verified"
76 else
77 echo "FAILED: token oemid not verified"
78 echo 'TEST FAILED.' > /workspace/status.txt
79 print_serial=true
80 fi
81
82 if echo $SERIAL_OUTPUT | grep -q 'hwmodel: fake-hw-model'
83 then
84 echo "- token hwmodel verified"
85 else
86 echo "FAILED: token hwmodel not verified"
87 echo 'TEST FAILED.' > /workspace/status.txt
88 print_serial=true
89 fi
90
91 if echo $SERIAL_OUTPUT | grep -q 'swname: fake-sw-name'
92 then
93 echo "- token swname verified"
94 else
95 echo "FAILED: token swname not verified"
96 echo 'TEST FAILED.' > /workspace/status.txt
97 print_serial=true
98 fi
99
100 if echo $SERIAL_OUTPUT | grep -q 'Token looks okay'
101 then
102 echo "- OIDC token accessible"
103 else
104 echo "FAILED: OIDC token not accessible"
105 echo 'TEST FAILED.' > /workspace/status.txt
106 print_serial=true
107 fi
108
109 if $print_serial; then
110 echo $SERIAL_OUTPUT
111 fi