Debian Codegraph @

docs/software_dev/test.rst

raw
1 .. _test_app:
2
3 Testing buskill-app
4 ====================
5
6 This section documents how to test the BusKill App.
7
8 .. note::
9
10 Currently we don't have any automated tests. While we'd like to change that, it's not clear how to simulate USB hotplug events in automated tests. Progress on this research can be found here:
11
12 * https://github.com/BusKill/buskill-app/issues/32
13 * https://github.com/BusKill/buskill-app/issues/38
14 * https://stackoverflow.com/questions/74090470/simulating-a-hotplug-event-with-libusb-test-debugging
15
16 Linux
17 -----
18
19 Because of how easy it is to quickly "install" and launch various Linux distributions in a new docker container, Linux is the easiest platform on which to test the BusKill app.
20
21 .. note::
22
23 Currently it's not possible to automate these tests on GitHub because nested virtualization is not available on shared GitHub Runners. For more info, see
24
25 * https://github.com/BusKill/buskill-app/issues/32#issuecomment-1207248758
26 * https://github.com/actions/runner-images/issues/183
27
28 On a machine that supports nested virtualization (eg your laptop), execute the following commands to launch the BusKill app in CLI mode on a dozen or so different Linux distributions (Note: Replace BUSKILL_RELEASE_URL with a link to the release you'd like to test).
29
30 ::
31
32 sudo apt-get install docker.io
33 sudo bash -c 'gpasswd -a "${SUDO_USER}" docker'
34 su - `whoami`
35
36 BUSKILL_RELEASE_URL='https://github.com/BusKill/buskill-app/releases/download/3309700248_linux/buskill-lin-v0.6.0-x86_64.tbz'
37 DOCKER_IMAGES='ubuntu:14.04 ubuntu:16.04 ubuntu:18.04 ubuntu:20.04 ubuntu:22.04 debian:oldstable-slim debian:stable-slim fedora:35 fedora:36 fedora:37'
38
39 tmpDir=`mktemp -d`
40 pushd "${tmpDir}"
41
42 wget "${BUSKILL_RELEASE_URL}"
43 tar -xjvf buskill-lin-*.tbz
44 buskill_release_dir=`find "${tmpDir}" -mindepth 1 -maxdepth 1 -type d`
45
46 # create script for this iteration of the loop
47 cat > "runInDockerContainer.sh" <<EOF
48 #!/bin/bash
49 apt-get update
50 apt-get install -y libfuse2 libusb-1.0-0-dev
51 /root/buskill-app/buskill-*/buskill-*.AppImage --arm
52 EOF
53 chmod +x runInDockerContainer.sh
54
55 for image in ${DOCKER_IMAGES}; do
56
57 # create script for this iteration of the loop
58 script_path="${image}.sh"
59 cat > "${script_path}" <<EOF
60 echo ${image}
61
62 cd "${buskill_release_dir}"
63 export DOCKER_CONTENT_TRUST=1
64 docker run --privileged --rm --net host -v /run/udev/control:/run/udev/control -v "`pwd`:/root/buskill-app" -it ${image} /root/buskill-app/runInDockerContainer.sh
65
66 read waiting
67 EOF
68 chmod +x "${script_path}"
69
70 x-terminal-emulator -e bash ${script_path} &
71 done
72
73 Windows
74 -------
75
76 Linux users can test on Windows by running Windows in a VM. Microsoft provides free downloads of Windows 10 for 90-days for testing purposes, which can be found here:
77
78 * https://www.microsoft.com/en-us/evalcenter/evaluate-windows-10-enterprise
79
80 If you're struggling to get USB passthrough to work in you VM software (eg Xen, VMWare, VirtualBox, etc), you can instead create a "Virtual Hard Drive" using built-in Microsoft tools. Mounting the VHD will cause a USB Hotplug event. Removing the VHD will cause a USB Hotplug Removal event, which will simulate the removal of the BusKill cable and cause the BusKill app to execute the trigger.
81
82 To create a new VHD on Windows 10:
83
84 #. Click inside "Type here to search"
85 #. Type "Disk Management"
86 #. Click on "Create and format hard disk partitions"
87 #. On the new window, click "Action" -> "Create VHD"
88 #. Click "Browse"
89 #. Type "BusKill" for "Location" to create a file named "BusKill.vhd"
90 #. Click "Save"
91 #. Type "10" for "Virtual hard disk size" (to create a 10 MB VHD)
92 #. Click "OK"
93 #. Click "Action" -> "Attach VHD"
94 #. Click "Browse"
95 #. Click "BusKill.vhd"
96 #. Click "Open"
97 #. Click "OK"
98 #. Scroll-down in the bottom-half of the "Disk Management" window, and right-click the left part of the new 10 MB "Unknown" disk. Select "Initalize Disk"
99 #. Click "OK"
100 #. Right-click the right part of the new disk (9 MB Unallocated). Select "New Simple Volume".
101 #. Click "Next". Click "Next". Click "Next". Click "Next". Click "Finish".
102 #. Open Windows Explorer and go to "This PC". You'll see a "New Volume".
103
104 You can now open the BusKill app and arm it. If you eject the "New Volume" (right click it and select "Eject", then the BusKill app will execute the configured trigger.
105
106 You can re-attach the VHD by opening "Disk Management" and going to "Action" -> "Attach VHD"
107
108 MacOS
109 -----
110
111 Apple is very hostile to developers, and they don't make it easy run MacOS in a VM on Linux.
112
113 If you know of a way to:
114
115 #. Easily run MacOS in a VM, and/or
116 #. Simulate USB hotplug events in a headless machine running MacOS
117
118 ...then please do `contact us <https://buskill.in/contact/>`_.
119
120 Fortunately, the BusKill project is `sponsored by Mac Stadium <https://www.macstadium.com/opensource>`_. They donated a Mac Mini to us, which runs in their cloud. We tunnel VNC through SSH and use it to test the BusKill app.
121
122 .. note::
123
124 We don't know of any way to simulate USB Hotplug events on MacOS, so we just use the ``--run-trigger`` argument to the BusKill app to confirm that our triggers on MacOS work.
125
126 If you have a machine running MacOS, one simple thing you can do to :ref:`help the BusKill project<contributing>` is offer to test new releases on MacOS. If you'd like to help us test BusKill on MacOS, please `contact us <https://buskill.in/contact/>`_.