Skip to content

Instantly share code, notes, and snippets.

@thaddeusc1
Last active June 28, 2022 06:05
Show Gist options
  • Save thaddeusc1/6b75a68bfee581a93e4e75f8e3a8a2c6 to your computer and use it in GitHub Desktop.
Save thaddeusc1/6b75a68bfee581a93e4e75f8e3a8a2c6 to your computer and use it in GitHub Desktop.
Modifying the Phoronix Test Suite's selenium test profile for testing with Firefox Flatpak and Chrome Flatpak web browsers
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--- .phoronix-test-suite/test-profiles/system/selenium-1.0.30/install.sh 2022-06-21 23:10:54.000000000 +0000
+++ .phoronix-test-suite/test-profiles/system/selenium-flatpak/install.sh 2022-06-28 04:22:44.082798022 +0000
@@ -1,14 +1,40 @@
#!/bin/bash
+echo 0 > ~/install-exit-status
+
+echo "#!/bin/bash
if which pip3>/dev/null 2>&1 ;
then
- echo 0 > ~/install-exit-status
+ pip3 install --user selenium==3.141.0
else
- echo "ERROR: Python pip3 is not found on the system! This test profile needs Python pip3 to proceed."
- echo 2 > ~/install-exit-status
+ echo \"ERROR: Python pip3 is not found within the flatpak SDK for \$(ls ~/.var/app)! This test profile needs Python pip3 to proceed.\"
+ echo 2 > $HOME/install-exit-status
fi
+" > install-inside-sandbox.sh
+chmod +x install-inside-sandbox.sh
+
+readonly Restore_ShellOption_State=`shopt -p extglob`
+if shopt -s extglob ;
+then
+ if shopt -q extglob ;
+ then
+ for flatpak_browser in org.mozilla.firefox com.google.Chrome
+ do
+ HOME="/home/`whoami`" flatpak install --assumeyes --noninteractive --app --user $flatpak_browser
+ sdk=$(HOME="/home/`whoami`" flatpak info $flatpak_browser | grep Sdk)
+ HOME="/home/`whoami`" flatpak install --assumeyes --noninteractive --runtime --user ${sdk##*([[:space:]])Sdk:[[:space:]]}
+ HOME="/home/`whoami`" flatpak run --devel --filesystem=`pwd` --command=./install-inside-sandbox.sh $flatpak_browser
+ done
+ else
+ echo "ERROR: Unable to set (i.e., enable) the shell option: extglob."
+ echo 4 > ~/install-exit-status
+ fi # shopt -q extglob ;
+else
+ echo "ERROR: The shell option for 'extglob' is invalid / unsupported."
+ echo 3 > ~/install-exit-status
+fi # shopt -s extglob ;
-pip3 install --user selenium==3.141.0
+$Restore_ShellOption_State
unzip -o selenium-scripts-9.zip
@@ -37,10 +63,21 @@
print('{0} {1}'.format(browserName, browserVersion))
driver.quit()\" > browser-version.py
-PATH=\$HOME:\$PATH python3 ./run-benchmark.py > \$LOG_FILE 2>&1
-echo \$? > ~/test-exit-status
+echo \"#!/bin/bash
+PATH=\$HOME:\\\$PATH python3 ./run-benchmark.py > \$LOG_FILE 2>&1
+echo \\\$? > \$HOME/test-exit-status
+
+PATH=\$HOME:\\\$PATH python3 ./browser-version.py > \$HOME/pts-footnote
+\" > selenium-flatpak.sh
+chmod +x selenium-flatpak.sh
+
+case \$2 in
+ Chrome) flatpak_app='com.google.Chrome' ;;
+ Firefox) flatpak_app='org.mozilla.firefox' ;;
+ *) flatpak_app=\"error.UnknownBrowser.\$2\" ;;
+esac
-PATH=\$HOME:\$PATH python3 ./browser-version.py > ~/pts-footnote
+HOME=\"/home/\`whoami\`\" flatpak run --filesystem=\`pwd\` --command=./selenium-flatpak.sh \$flatpak_app
" > selenium
chmod +x selenium
@thaddeusc1
Copy link
Author

thaddeusc1 commented Jun 20, 2022

Compatible with Phoronix Test Suite's selenium profile v1.0.29.

@thaddeusc1
Copy link
Author

thaddeusc1 commented Jun 28, 2022

Compatible with Phoronix Test Suite's selenium test profile v1.0.30. Recommended method to patch the test profile:

patch --backup --directory=$HOME --strip=0 --set-utc < /path/to/install.sh.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment