Debian Codegraph @

debian/tests/myapp-clang

raw symbols SCIP
1 #!/bin/bash
2
3 set -euo pipefail
4 IFS=$'\n\t'
5
6 if [ ! -e /dev/urandom ]; then
7 echo "There is no /dev/urandom."
8 exit 1
9 fi
10
11 kodev create myapp
12 cd myapp || exit 1
13
14 kodev info
15
16 timeout --preserve-status -k 60s -s SIGQUIT 60s kodev run &
17
18 sleep 5
19
20 # Find the parent and child processes
21 PARENT_PID=$(pgrep -o kore)
22 CHILD_PIDS=$(pgrep -P "$PARENT_PID")
23
24 # Assume everything is OK initially
25 ALL_OK=true
26
27 # If no child processes are found, print a message and exit
28 if [ -z "$CHILD_PIDS" ]; then
29 echo "No kore child processes found."
30 exit
31 fi
32
33 # Check each child process
34 for PID_CHILD in $CHILD_PIDS; do
35 # Get the Seccomp status code (the number only)
36 STATUS_CODE=$(grep '^Seccomp:' "/proc/$PID_CHILD/status" | awk '{print $2}')
37
38 if [ "$STATUS_CODE" -ne 2 ]; then
39 echo "[X] Warning! Process PID: $PID_CHILD has Seccomp status $STATUS_CODE (not 2)"
40 ALL_OK=false
41 fi
42 done
43
44 # Print the final conclusion based on the check
45 if [ "$ALL_OK" = true ]; then
46 echo "[OK] All child processes have Seccomp status 2. The security sandbox is enabled correctly."
47 else
48 echo "[ERROR] Please note: Not all child processes are in Seccomp mode 2."
49 exit 1
50 fi
51
52 # A concise and robust loop to wait for a service to be ready.
53 for _ in {1..10}; do
54 # Use --spider: doesn't download the page, just checks if it's there.
55 # It's more efficient for a health check. Output is silenced.
56 if wget --spider -q -T 5 --tries=1 --no-check-certificate https://127.0.0.1:8888 2>/dev/null; then
57 # If wget succeeds, break the loop.
58 break
59 fi
60 # If it fails, wait a second before the next attempt.
61 sleep 1
62 done
63
64 # After the loop, check one last time. If it still fails, the service is truly down.
65 # This check ensures that the loop didn't just end on its 10th (failed) attempt.
66 if ! wget --spider -q -T 5 --tries=1 --no-check-certificate https://127.0.0.1:8888 2>/dev/null; then
67 echo "ERROR: Service at https://127.0.0.1:8888 not ready after 10 attempts." >&2
68 exit 1
69 else
70 echo "[OK] Service is ready at https://127.0.0.1:8888"
71 fi
72
73 cd ..
74
75 rm -fr myapp
76
77 kill -SIGQUIT "$PARENT_PID"
78
79 # Wait for the kore process to actually terminate
80 for _ in {1..10}; do
81 if ! pgrep -P "$PARENT_PID" > /dev/null; then
82 break
83 fi
84 sleep 1
85 done