Skip to content

Commit ddd46ee

Browse files
authored
Merge pull request #44 from greygoo/add_cli_support
Add cli support
2 parents 3c2796a + 2acd66a commit ddd46ee

18 files changed

+900
-14
lines changed

tests/cenity/d_feeder.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
mkfifo encrypt_pipe
4+
5+
sleep 5
6+
echo "# first line" > encrypt_pipe
7+
sleep 1
8+
echo "# second line" > encrypt_pipe
9+
sleep 2
10+
echo "invisible line" > encrypt_pipe
11+
sleep 1
12+
echo "# third line" > encrypt_pipe
13+
sleep 1
14+
echo "100" > encrypt_pipe
15+
16+
rm encrypt_pipe

tests/cenity/d_function_test

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
cenity="../../usr/lib/tik/lib/cenity"
2+
. $cenity
3+
4+
compare() {
5+
diff -y <(echo "$1") <(echo "$2") || RESULT=$((RESULT+1))
6+
}
7+
8+
string_test() {
9+
local strings=("$@")
10+
11+
echo "$strings"
12+
13+
for i in "${strings[@]}"; do
14+
echo "Testing $i"
15+
if grep "$i" "/tmp/out"; then
16+
echo "$i found - passed"
17+
else
18+
echo "$i not found - failed"
19+
RESULT=1
20+
fi
21+
done
22+
}
23+
24+
check_result() {
25+
if [ $RESULT -gt 0 ]; then
26+
echo "$0 FAILED"
27+
exit 1
28+
else
29+
echo "$0 PASSED"
30+
exit 0
31+
fi
32+
33+
echo "Error"
34+
exit 255
35+
}
36+
37+
c_test() {
38+
unset c_retval
39+
40+
cenity c_result "$@" || c_retval=$?
41+
echo "[cenity][${c_retval}][${c_result}] $@"
42+
}
43+
44+
z_test() {
45+
unset z_retval
46+
47+
z_result="$(zenity "$@")" || z_retval=$?
48+
echo "[zenity][${z_retval}][${z_result}] $@"
49+
}

tests/cenity/run_tests.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
PASSED=0
4+
FAILED=0
5+
6+
for test in tik_*; do
7+
RESULT=0
8+
echo "Running: ${test}"
9+
./${test} || RESULT=1
10+
echo "Test result for ${test}: $RESULT"
11+
if [ $RESULT == 1 ]; then
12+
FAILED=$((FAILED+1))
13+
elif [ $RESULT == 0 ]; then
14+
PASSED=$((PASSED+1))
15+
else
16+
echo error
17+
fi
18+
done
19+
20+
echo "Tests passed: $PASSED"
21+
echo "Tests failed: $FAILED"
22+
23+
if [ $FAILED -gt 0 ]; then
24+
exit 1
25+
else
26+
exit 0
27+
fi

tests/cenity/template

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
#######################################
8+
asserted_output="$(echo -e '<EXPECTED OUTPUT>')"
9+
output="$(c_test <options> <<< <input> 2>&1)"
10+
compare "$output" "$asserted_output"
11+
12+
check_result

tests/cenity/tik_entry.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
#######################################
8+
asserted_output="$(echo -e '--ENTRY----- This is a ENTRY ----------------
9+
10+
[cenity][][Test entry] --entry --text=This is a entry text --title=This is a ENTRY')"
11+
output="$(c_test --entry --text="This is a entry text" --title="This is a ENTRY" <<< "Test entry" 2>&1)"
12+
compare "$output" "$asserted_output"
13+
14+
check_result

tests/cenity/tik_error.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
#######################################
8+
asserted_output="$(echo -e '--ERROR----- Installation Failed ----------------
9+
10+
Please file a bug report at \033[1mTEST URL\033[0m
11+
12+
Please include the \033[1mtik.log\033[0m file
13+
It can be found on the IGNITION partition on this USB Stick
14+
15+
\033[1mSystem is shutting down\033[0m
16+
17+
Press key to continue
18+
[cenity][][] --error --no-wrap --title=Installation Failed --text=Please file a bug report at <tt>TEST URL</tt>\\n\\nPlease include the <tt>tik.log</tt> file\\nIt can be found on the IGNITION partition on this USB Stick\\n\\n<b>System is shutting down</b>')"
19+
output="$(c_test --error --no-wrap --title="Installation Failed" --text="Please file a bug report at <tt>TEST URL</tt>\n\nPlease include the <tt>tik.log</tt> file\nIt can be found on the IGNITION partition on this USB Stick\n\n<b>System is shutting down</b>" <<< "\n" 2>&1)"
20+
compare "$output" "$asserted_output"
21+
22+
check_result

tests/cenity/tik_info.sh

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
#######################################
8+
asserted_output="$(echo -e '--INFO------ ----------------
9+
10+
\033[1mTest Succeeded:\033[0m
11+
12+
Have a nice day!
13+
14+
Press key to continue
15+
[cenity][][] --timeout 5 --info --no-wrap --text=<b>Test Succeeded:</b>\\n\\nHave a nice day!')"
16+
output="$(c_test --timeout 5 --info --no-wrap --text="<b>Test Succeeded:</b>\n\nHave a nice day!" <<< "\n" 2>&1)"
17+
compare "$output" "$asserted_output"
18+
19+
20+
#######################################
21+
asserted_output="$(echo -e '--INFO------ Installation Complete! ----------------
22+
23+
TIK_OS_NAME has been installed.
24+
25+
\033[1mSystem is rebooting\033[0m
26+
27+
Press key to continue
28+
[cenity][][] --timeout 5 --info --no-wrap --title=Installation Complete! --text=TIK_OS_NAME has been installed.\\n\\n<b>System is rebooting</b>')"
29+
output="$(c_test --timeout 5 --info --no-wrap --title="Installation Complete!" --text="TIK_OS_NAME has been installed.\n\n<b>System is rebooting</b>" <<< "\n" 2>&1)"
30+
compare "$output" "$asserted_output"
31+
32+
33+
#######################################
34+
asserted_output="$(echo -e '--WARNING--- Encryption Recovery Key -------------security-high--
35+
36+
You may optionally scan the recovery key off screen:
37+
38+
39+
█▀▀▀▀▀█ ▀ █ █▀▀▀▀▀█
40+
█ ███ █ ▀ ▀ ▄ █ ███ █
41+
█ ▀▀▀ █ █▄█▀ █ ▀▀▀ █
42+
▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
43+
▀█▀▄█▀▀▀▀ █▄▀█▀▄ ▀▄▄
44+
▄ █ ▄▄▀▄▄▄ █▄█▀█▄▀▀█▀
45+
▀ ▀ ▀ █▄▄▀ ▀█▀ █ ▀█
46+
█▀▀▀▀▀█ █▄▀ ▀ ▄ ▀▀ █▀
47+
█ ███ █ ▀▀▄▄▀▄▀▄▀▀ █▀
48+
█ ▀▀▀ █ █▀▄█▄█▀█▄▄▀▄▀
49+
▀▀▀▀▀▀▀ ▀▀ ▀ ▀▀▀ ▀▀▀
50+
51+
52+
For more information please visit \033[1mhttps://aeondesktop.org/encrypt\033[0m
53+
54+
Press key to continue
55+
[cenity][][] --width=500 --height=500 --no-wrap --warning --icon=security-high-symbolic --title=Encryption Recovery Key --text=You may optionally scan the recovery key off screen:\\n<span face='\''monospace'\''>
56+
57+
█▀▀▀▀▀█ ▀ █ █▀▀▀▀▀█
58+
█ ███ █ ▀ ▀ ▄ █ ███ █
59+
█ ▀▀▀ █ █▄█▀ █ ▀▀▀ █
60+
▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
61+
▀█▀▄█▀▀▀▀ █▄▀█▀▄ ▀▄▄
62+
▄ █ ▄▄▀▄▄▄ █▄█▀█▄▀▀█▀
63+
▀ ▀ ▀ █▄▄▀ ▀█▀ █ ▀█
64+
█▀▀▀▀▀█ █▄▀ ▀ ▄ ▀▀ █▀
65+
█ ███ █ ▀▀▄▄▀▄▀▄▀▀ █▀
66+
█ ▀▀▀ █ █▀▄█▄█▀█▄▄▀▄▀
67+
▀▀▀▀▀▀▀ ▀▀ ▀ ▀▀▀ ▀▀▀
68+
69+
</span>\\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>')"
70+
output="$(c_test --width=500 --height=500 --no-wrap --warning --icon=security-high-symbolic --title="Encryption Recovery Key" --text="${message}You may optionally scan the recovery key off screen:\n<span face='monospace'>$(qrencode test -t UTF8i)</span>\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>" <<< "\n" 2>&1)"
71+
compare "$output" "$asserted_output"
72+
73+
74+
#######################################
75+
asserted_output="$(echo -e '--WARNING--- Set Encryption Passphrase -------------security-high--
76+
77+
This system is encrypted and will require a Passphrase on every boot
78+
79+
You will be prompted to set the Passphrase on the next screen
80+
81+
For more information please visit \033[1mhttps://aeondesktop.org/encrypt\033[0m
82+
83+
Press key to continue
84+
[cenity][][] --width=500 --height=300 --no-wrap --warning --icon=security-high-symbolic --title=Set Encryption Passphrase --text=This system is encrypted and will require a Passphrase on every boot\\n\\nYou will be prompted to set the Passphrase on the next screen\\n\\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>')"
85+
output="$(c_test --width=500 --height=300 --no-wrap --warning --icon=security-high-symbolic --title="Set Encryption Passphrase" --text="This ${TIK_OS_NAME} system is encrypted and will require a Passphrase on every boot\n\nYou will be prompted to set the Passphrase on the next screen\n\nFor more information please visit <tt>https://aeondesktop.org/encrypt</tt>" <<< "\n" 2>&1)"
86+
compare "$output" "$asserted_output"
87+
88+
89+
#######################################
90+
asserted_output="$(echo -e '--INFO------ Message from the Aeon Team ----------------
91+
92+
We'\''d like to thank you for adopting openSUSE Aeon so early in it'\''s development,
93+
before we fully understood what we were building or how we wanted it to look
94+
95+
We are sorry that you need to reinstall your system
96+
97+
Thank you so much for your support.
98+
We hope you enjoy the new look openSUSE Aeon
99+
100+
Press key to continue
101+
[cenity][][] --info --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --no-wrap --title=Message from the Aeon Team --text=We'\''d like to thank you for adopting openSUSE Aeon so early in it'\''s development,\\nbefore we fully understood what we were building or how we wanted it to look\\n\\nWe are sorry that you need to reinstall your system\\n\\nThank you so much for your support.\\nWe hope you enjoy the new look openSUSE Aeon')"
102+
output="$(c_test --info --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --no-wrap --title="Message from the Aeon Team" --text="We'd like to thank you for adopting openSUSE Aeon so early in it's development,\nbefore we fully understood what we were building or how we wanted it to look\n\nWe are sorry that you need to reinstall your system\n\nThank you so much for your support.\nWe hope you enjoy the new look openSUSE Aeon" <<< "\n" 2>&1)"
103+
compare "$output" "$asserted_output"
104+
105+
106+
# TODO: handle ok label
107+
#output=$(c_test --info --ok-label="Install Now" --no-wrap --width=300 --height=300 --icon=distributor-logo-Aeon-symbolic --title="" --text="<big>Welcome to ${TIK_OS_NAME}</big>\n\nPlease press <b>Install Now</b> to continue")
108+
109+
tput sgr0
110+
check_result

tests/cenity/tik_list.sh

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
list_items=' virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test2 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test3 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)'
8+
#######################################
9+
asserted_output="$(echo -e '--LIST------ Select A Disk ----------------
10+
11+
Select the disk to install the operating system to.
12+
13+
\033[1mMake sure any important documents and files have been backed up.\033[0m
14+
15+
Item Disk Size Partitions Filesystems
16+
0: virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
17+
1: virtio-test2 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
18+
2: virtio-test3 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
19+
20+
Please select a item number
21+
[cenity][][virtio-test3] --list --column=Disk --column=Size --column=Partitions --column=Filesystems --width=1050 --height=340 --title=Select A Disk --text=Select the disk to install the operating system to.\\n\\n<b>Make sure any important documents and files have been backed up.</b>\\n virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test2 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test3 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)')"
22+
output="$(c_test --list --column=Disk --column=Size --column=Partitions --column=Filesystems --width=1050 --height=340 --title="Select A Disk" --text="Select the disk to install the operating system to.\n\n<b>Make sure any important documents and files have been backed up.</b>\n" ${list_items} <<< "2" 2>&1)"
23+
compare "$output" "$asserted_output"
24+
25+
26+
#######################################
27+
asserted_output="$(echo -e '--LIST------ Select A Disk ----------------
28+
29+
Select the disk to install the operating system to.
30+
31+
\033[1mMake sure any important documents and files have been backed up.\033[0m
32+
33+
Item Disk Size Partitions Filesystems
34+
0: virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
35+
1: virtio-test2 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
36+
2: virtio-test3 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)
37+
38+
Please select a item number
39+
[cenity][][virtio-test2] --list --column=Disk --column=Size --column=Partitions --column=Filesystems --width=1050 --height=340 --title=Select A Disk --text=Select the disk to install the operating system to.\\n\\n<b>Make sure any important documents and files have been backed up.</b>\\n virtio-0987654321 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test2 20G 3 unknown(2M),vfat(20M),btrfs(4.3G) virtio-test3 20G 3 unknown(2M),vfat(20M),btrfs(4.3G)')"
40+
output="$(c_test --list --column=Disk --column=Size --column=Partitions --column=Filesystems --width=1050 --height=340 --title="Select A Disk" --text="Select the disk to install the operating system to.\n\n<b>Make sure any important documents and files have been backed up.</b>\n" ${list_items} <<< "1" 2>&1)"
41+
compare "$output" "$asserted_output"
42+
43+
44+
list_items='tik-osimage-Aeon.20240731.raw.xz 1501130408 tik-osimage-Aeon.test2.raw.xz 1501130408 tik-osimage-Aeon.test3.raw.xz 1501130408'
45+
#######################################
46+
asserted_output="$(echo -e '--LIST------ Select A Image ----------------
47+
48+
Select the operating system image to install.
49+
50+
Item Image Size
51+
0: tik-osimage-Aeon.20240731.raw.xz 1501130408
52+
1: tik-osimage-Aeon.test2.raw.xz 1501130408
53+
2: tik-osimage-Aeon.test3.raw.xz 1501130408
54+
55+
Please select a item number
56+
[cenity][][tik-osimage-Aeon.test2.raw.xz] --list --column=Image --column=Size --title=Select A Image --text=Select the operating system image to install.\\n tik-osimage-Aeon.20240731.raw.xz 1501130408 tik-osimage-Aeon.test2.raw.xz 1501130408 tik-osimage-Aeon.test3.raw.xz 1501130408')"
57+
output="$(c_test --list --column=Image --column=Size --title="Select A Image" --text="Select the operating system image to install.\n" ${list_items} <<< "1" 2>&1)"
58+
compare "$output" "$asserted_output"
59+
60+
61+
#######################################
62+
asserted_output="$(echo -e '--LIST------ Select A Image ----------------
63+
64+
Select the operating system image to install.
65+
66+
Item Image Size
67+
0: tik-osimage-Aeon.20240731.raw.xz 1501130408
68+
1: tik-osimage-Aeon.test2.raw.xz 1501130408
69+
2: tik-osimage-Aeon.test3.raw.xz 1501130408
70+
71+
Please select a item number
72+
[cenity][][tik-osimage-Aeon.test3.raw.xz] --list --column=Image --column=Size --title=Select A Image --text=Select the operating system image to install.\\n tik-osimage-Aeon.20240731.raw.xz 1501130408 tik-osimage-Aeon.test2.raw.xz 1501130408 tik-osimage-Aeon.test3.raw.xz 1501130408')"
73+
output="$(c_test --list --column=Image --column=Size --title="Select A Image" --text="Select the operating system image to install.\n" ${list_items} <<< "2" 2>&1)"
74+
compare "$output" "$asserted_output"
75+
76+
check_result

tests/cenity/tik_password.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
. ./d_function_test
4+
5+
RESULT=0
6+
7+
#######################################
8+
asserted_output="$(echo -e '--PASSWORD-- Set Encryption Passphrase ----------------
9+
10+
[cenity][][test] --password --title=Set Encryption Passphrase')"
11+
output="$(c_test --password --title='Set Encryption Passphrase' <<< "test" 2>&1)"
12+
compare "$output" "$asserted_output"
13+
14+
15+
# TODO: Fix cancel-label
16+
#######################################
17+
#asserted_output="$(echo -e 'EXPECTED OUTPUT')"
18+
#output="$(c_test --password --title='Encrypted partition (/devsda) detected' --cancel-label='Skip' <<< "test" 2>&1)"
19+
#compare "$output" "$asserted_output"
20+
21+
check_result

0 commit comments

Comments
 (0)