1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Oracle VM VirtualBox
|
---|
4 | # VirtualBox linux installation script unit test
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2007-2011 Oracle Corporation
|
---|
8 | #
|
---|
9 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | # available from http://www.virtualbox.org. This file is free software;
|
---|
11 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | # General Public License (GPL) as published by the Free Software
|
---|
13 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | #
|
---|
17 |
|
---|
18 | #include installer-utils.sh
|
---|
19 |
|
---|
20 | CERRS=0
|
---|
21 |
|
---|
22 | echo "Testing udev rule generation"
|
---|
23 |
|
---|
24 | setup_test_input_install_udev ".run, udev-59" 59
|
---|
25 |
|
---|
26 | udev_59_rules=`cat <<'UDEV_END'
|
---|
27 | KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
|
---|
28 | SUBSYSTEM=="usb_device", ACTION=="add", RUN+="/opt/VirtualBox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
|
---|
29 | SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN+="/opt/VirtualBox/VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
|
---|
30 | SUBSYSTEM=="usb_device", ACTION=="remove", RUN+="/opt/VirtualBox/VBoxCreateUSBNode.sh --remove $major $minor"
|
---|
31 | SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", RUN+="/opt/VirtualBox/VBoxCreateUSBNode.sh --remove $major $minor"
|
---|
32 | UDEV_END`
|
---|
33 |
|
---|
34 | install_udev_output="`install_udev vboxusers 0660 /opt/VirtualBox`"
|
---|
35 | case "$install_udev_output" in
|
---|
36 | "$udev_59_rules") ;;
|
---|
37 | *)
|
---|
38 | echo "Bad output for udev version 59. Expected:"
|
---|
39 | echo "$udev_59_rules"
|
---|
40 | echo "Actual:"
|
---|
41 | echo "$install_udev_output"
|
---|
42 | CERRS="`expr "$CERRS" + 1`"
|
---|
43 | ;;
|
---|
44 | esac
|
---|
45 |
|
---|
46 | cleanup_test_input_install_udev
|
---|
47 |
|
---|
48 | setup_test_input_install_udev ".run, udev-55" 55
|
---|
49 |
|
---|
50 | udev_55_rules=`cat <<'UDEV_END'
|
---|
51 | KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
|
---|
52 | UDEV_END`
|
---|
53 |
|
---|
54 | install_udev_output="`install_udev vboxusers 0660 /opt/VirtualBox`"
|
---|
55 | case "$install_udev_output" in
|
---|
56 | "$udev_55_rules") ;;
|
---|
57 | *)
|
---|
58 | echo "Bad output for udev version 55. Expected:"
|
---|
59 | echo "$udev_55_rules"
|
---|
60 | echo "Actual:"
|
---|
61 | echo "$install_udev_output"
|
---|
62 | CERRS="`expr "$CERRS" + 1`"
|
---|
63 | ;;
|
---|
64 | esac
|
---|
65 |
|
---|
66 | cleanup_test_input_install_udev
|
---|
67 |
|
---|
68 | setup_test_input_install_udev ".run, udev-54" 54
|
---|
69 |
|
---|
70 | udev_54_rules=`cat <<'UDEV_END'
|
---|
71 | KERNEL="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600"
|
---|
72 | UDEV_END`
|
---|
73 |
|
---|
74 | install_udev_output="`install_udev root 0600 /usr/lib/virtualbox`"
|
---|
75 | case "$install_udev_output" in
|
---|
76 | "$udev_54_rules") ;;
|
---|
77 | *)
|
---|
78 | echo "Bad output for udev version 54. Expected:"
|
---|
79 | echo "$udev_54_rules"
|
---|
80 | echo "Actual:"
|
---|
81 | echo "$install_udev_output"
|
---|
82 | CERRS="`expr "$CERRS" + 1`"
|
---|
83 | ;;
|
---|
84 | esac
|
---|
85 |
|
---|
86 | cleanup_test_input_install_udev
|
---|
87 |
|
---|
88 | echo "Testing device node setup"
|
---|
89 |
|
---|
90 | unset INSTALL_NO_GROUP
|
---|
91 | unset INSTALL_NO_UDEV
|
---|
92 | setup_test_input_install_device_node_setup vboxusers 0660 /opt/VirtualBox \
|
---|
93 | vboxusb
|
---|
94 |
|
---|
95 | command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb"
|
---|
96 | err="`${command} 2>&1`"
|
---|
97 | test -n "${err}" && {
|
---|
98 | echo "${command} failed."
|
---|
99 | echo "Error: ${err}"
|
---|
100 | CERRS="`expr "$CERRS" + 1`"
|
---|
101 | }
|
---|
102 |
|
---|
103 | cleanup_test_input_install_device_node_setup
|
---|
104 |
|
---|
105 | INSTALL_NO_GROUP=1
|
---|
106 | unset INSTALL_NO_UDEV
|
---|
107 | setup_test_input_install_device_node_setup root 0660 /opt/VirtualBox root
|
---|
108 |
|
---|
109 | command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb"
|
---|
110 | err="`${command} 2>&1`"
|
---|
111 | test -n "${err}" && {
|
---|
112 | echo "${command} failed."
|
---|
113 | echo "Error: ${err}"
|
---|
114 | CERRS="`expr "$CERRS" + 1`"
|
---|
115 | }
|
---|
116 |
|
---|
117 | cleanup_test_input_install_device_node_setup
|
---|
118 |
|
---|
119 | unset INSTALL_NO_GROUP
|
---|
120 | INSTALL_NO_UDEV=1
|
---|
121 | setup_test_input_install_device_node_setup vboxusers 0660 /opt/VirtualBox \
|
---|
122 | vboxusb
|
---|
123 |
|
---|
124 | command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb"
|
---|
125 | err="`${command} 2>&1`"
|
---|
126 | test -n "${err}" && {
|
---|
127 | echo "${command} failed."
|
---|
128 | echo "Error: ${err}"
|
---|
129 | CERRS="`expr "$CERRS" + 1`"
|
---|
130 | }
|
---|
131 |
|
---|
132 | cleanup_test_input_install_device_node_setup
|
---|
133 |
|
---|
134 | echo "Done. Error count $CERRS."
|
---|