From 2905b9f9ab5c5ed6f9210d1d843a8bcf41451854 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sat, 23 Apr 2016 08:53:07 -0400 Subject: make test-utils --- test/utils/caps-print.exp | 32 ++++++++++++++++++++++ test/utils/cpu-print.exp | 24 +++++++++++++++++ test/utils/dns-print.exp | 24 +++++++++++++++++ test/utils/fs-print.exp | 32 ++++++++++++++++++++++ test/utils/help.exp | 25 +++++++++++++++++ test/utils/list.exp | 51 +++++++++++++++++++++++++++++++++++ test/utils/man.exp | 20 ++++++++++++++ test/utils/protocol-print.exp | 24 +++++++++++++++++ test/utils/seccomp-print.exp | 36 +++++++++++++++++++++++++ test/utils/tree.exp | 63 +++++++++++++++++++++++++++++++++++++++++++ test/utils/utils.sh | 42 +++++++++++++++++++++++++++++ test/utils/version.exp | 18 +++++++++++++ 12 files changed, 391 insertions(+) create mode 100755 test/utils/caps-print.exp create mode 100755 test/utils/cpu-print.exp create mode 100755 test/utils/dns-print.exp create mode 100755 test/utils/fs-print.exp create mode 100755 test/utils/help.exp create mode 100755 test/utils/list.exp create mode 100755 test/utils/man.exp create mode 100755 test/utils/protocol-print.exp create mode 100755 test/utils/seccomp-print.exp create mode 100755 test/utils/tree.exp create mode 100755 test/utils/utils.sh create mode 100755 test/utils/version.exp (limited to 'test/utils') diff --git a/test/utils/caps-print.exp b/test/utils/caps-print.exp new file mode 100755 index 000000000..9cc4b1872 --- /dev/null +++ b/test/utils/caps-print.exp @@ -0,0 +1,32 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --caps.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "setgid - disabled" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "setuid - disabled" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "net_raw - disabled" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/cpu-print.exp b/test/utils/cpu-print.exp new file mode 100755 index 000000000..4a9ffa0ac --- /dev/null +++ b/test/utils/cpu-print.exp @@ -0,0 +1,24 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test --cpu=1,2\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --cpu.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Cpus_allowed_list: 1-2" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/dns-print.exp b/test/utils/dns-print.exp new file mode 100755 index 000000000..51dcab508 --- /dev/null +++ b/test/utils/dns-print.exp @@ -0,0 +1,24 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test --dns=1.2.3.4\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --dns.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "nameserver 1.2.3.4" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/fs-print.exp b/test/utils/fs-print.exp new file mode 100755 index 000000000..fa0eab95b --- /dev/null +++ b/test/utils/fs-print.exp @@ -0,0 +1,32 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --fs.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "blacklist /boot" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "blacklist /dev/kmsg" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "blacklist /proc/kmsg" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/help.exp b/test/utils/help.exp new file mode 100755 index 000000000..5b9864578 --- /dev/null +++ b/test/utils/help.exp @@ -0,0 +1,25 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --help\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "License GPL version 2 or later" +} +after 100 + +send -- "firejail -?\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "License GPL version 2 or later" +} +after 100 + +puts "\n" + diff --git a/test/utils/list.exp b/test/utils/list.exp new file mode 100755 index 000000000..69db1f568 --- /dev/null +++ b/test/utils/list.exp @@ -0,0 +1,51 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +sleep 1 + +spawn $env(SHELL) +send -- "firejail --list\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + ":firejail" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + ":firejail" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + ":firejail" +} +after 100 + + +puts "\n" + diff --git a/test/utils/man.exp b/test/utils/man.exp new file mode 100755 index 000000000..d29f760b0 --- /dev/null +++ b/test/utils/man.exp @@ -0,0 +1,20 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "man firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Linux namespaces sandbox program" +} +after 100 + +send -- "q\r" +after 100 +puts "\n" + diff --git a/test/utils/protocol-print.exp b/test/utils/protocol-print.exp new file mode 100755 index 000000000..152a64467 --- /dev/null +++ b/test/utils/protocol-print.exp @@ -0,0 +1,24 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --protocol.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "unix,inet,inet6" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/seccomp-print.exp b/test/utils/seccomp-print.exp new file mode 100755 index 000000000..d0531a9c3 --- /dev/null +++ b/test/utils/seccomp-print.exp @@ -0,0 +1,36 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --name=test\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --seccomp.print=test\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "EXAMINE_SYSCAL" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "init_module" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "delete_module" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "RETURN_ALLOW" +} +sleep 1 +puts "\nall done\n" diff --git a/test/utils/tree.exp b/test/utils/tree.exp new file mode 100755 index 000000000..a8ef763f1 --- /dev/null +++ b/test/utils/tree.exp @@ -0,0 +1,63 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Child process initialized" +} +after 100 + +spawn $env(SHELL) +send -- "firejail\r" +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "Child process initialized" +} +sleep 1 + +spawn $env(SHELL) +send -- "firejail --tree\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + ":firejail" +} +expect { + timeout {puts "TESTING ERROR 3.1\n";exit} + ":/bin/bash" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + ":firejail" +} +expect { + timeout {puts "TESTING ERROR 4.1\n";exit} + ":/bin/bash" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + ":firejail" +} +expect { + timeout {puts "TESTING ERROR 5.1\n";exit} + ":/bin/bash" +} +after 100 + + +puts "\n" + diff --git a/test/utils/utils.sh b/test/utils/utils.sh new file mode 100755 index 000000000..02aaa57c0 --- /dev/null +++ b/test/utils/utils.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +export MALLOC_CHECK_=3 +export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) + +echo "TESTING: version (test/utils/version.exp)" +./version.exp + +echo "TESTING: help (test/utils/help.exp)" +./help.exp + +echo "TESTING: man (test/utils/man.exp)" +./man.exp + +echo "TESTING: list (test/utils/list.exp)" +./list.exp + +echo "TESTING: tree (test/utils/tree.exp)" +./tree.exp + +echo "TESTING: cpu.print (test/utils/cpu-print.exp)" +echo "TESTING: failing under VirtualBox where there is only one CPU" +./cpu-print.exp + +echo "TESTING: fs.print (test/utils/fs-print.exp)" +./fs-print.exp + +echo "TESTING: dns.print (test/utils/dns-print.exp)" +./dns-print.exp + +echo "TESTING: caps.print (test/utils/caps-print.exp)" +./caps-print.exp + +echo "TESTING: seccomp.print (test/utils/seccomp-print.exp)" +./seccomp-print.exp + +echo "TESTING: protocol.print (test/utils/protocol-print.exp)" +./protocol-print.exp + diff --git a/test/utils/version.exp b/test/utils/version.exp new file mode 100755 index 000000000..2ce6f1680 --- /dev/null +++ b/test/utils/version.exp @@ -0,0 +1,18 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2016 Firejail Authors +# License GPL v2 + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --version\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "firejail version " +} +after 100 + +puts "\n" + -- cgit v1.2.3-70-g09d2