From c729d5927d5db964e71bfe30a269acf26786fef7 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sat, 23 Apr 2016 20:35:52 -0400 Subject: testing --- test/utils/catchsignal-master.sh | 4 +++ test/utils/catchsignal.sh | 27 ++++++++++++++++ test/utils/catchsignal2.sh | 49 ++++++++++++++++++++++++++++ test/utils/join-profile.exp | 39 +++++++++++++++++++++++ test/utils/join.exp | 42 ++++++++++++++++++++++++ test/utils/join2.exp | 42 ++++++++++++++++++++++++ test/utils/join3.exp | 42 ++++++++++++++++++++++++ test/utils/name.profile | 1 + test/utils/shutdown.exp | 33 +++++++++++++++++++ test/utils/shutdown2.exp | 45 ++++++++++++++++++++++++++ test/utils/shutdown3.exp | 65 +++++++++++++++++++++++++++++++++++++ test/utils/shutdown4.exp | 69 ++++++++++++++++++++++++++++++++++++++++ test/utils/utils.sh | 24 ++++++++++++++ 13 files changed, 482 insertions(+) create mode 100755 test/utils/catchsignal-master.sh create mode 100755 test/utils/catchsignal.sh create mode 100755 test/utils/catchsignal2.sh create mode 100755 test/utils/join-profile.exp create mode 100755 test/utils/join.exp create mode 100755 test/utils/join2.exp create mode 100755 test/utils/join3.exp create mode 100644 test/utils/name.profile create mode 100755 test/utils/shutdown.exp create mode 100755 test/utils/shutdown2.exp create mode 100755 test/utils/shutdown3.exp create mode 100755 test/utils/shutdown4.exp (limited to 'test/utils') diff --git a/test/utils/catchsignal-master.sh b/test/utils/catchsignal-master.sh new file mode 100755 index 000000000..62a1801cc --- /dev/null +++ b/test/utils/catchsignal-master.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +./catchsignal.sh & +./catchsignal.sh & diff --git a/test/utils/catchsignal.sh b/test/utils/catchsignal.sh new file mode 100755 index 000000000..87a1d0adf --- /dev/null +++ b/test/utils/catchsignal.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +_term() { + echo "Caught Signal" + echo 1 + sleep 1 + echo 2 + sleep 1 + echo 3 + sleep 1 + echo 4 + sleep 1 + echo 5 + sleep 1 + + kill $pid + exit +} + +trap _term SIGTERM +trap _term SIGINT + +echo "Sleeping..." + +sleep inf & +pid=$! +wait $pid diff --git a/test/utils/catchsignal2.sh b/test/utils/catchsignal2.sh new file mode 100755 index 000000000..424350397 --- /dev/null +++ b/test/utils/catchsignal2.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +_term() { + echo "Caught Signal" + echo 1 + sleep 1 + echo 2 + sleep 1 + echo 3 + sleep 1 + echo 4 + sleep 1 + echo 5 + sleep 1 + + echo 10 + sleep 1 + echo 20 + sleep 1 + echo 30 + sleep 1 + echo 40 + sleep 1 + echo 50 + sleep 1 + + echo 100 + sleep 1 + echo 200 + sleep 1 + echo 300 + sleep 1 + echo 400 + sleep 1 + echo 500 + sleep 1 + + kill $pid + exit +} + +trap _term SIGTERM +trap _term SIGINT + +echo "Sleeping..." + +sleep inf & +pid=$! +wait $pid diff --git a/test/utils/join-profile.exp b/test/utils/join-profile.exp new file mode 100755 index 000000000..9200980a1 --- /dev/null +++ b/test/utils/join-profile.exp @@ -0,0 +1,39 @@ +#!/usr/bin/expect -f + +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --profile=name.profile\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --join=jointesting;pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Switching to pid" +} +sleep 3 + + +spawn $env(SHELL) +send -- "firejail --shutdown=jointesting;pwd\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "home" +} +sleep 5 + +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "jointesting" {puts "TESTING ERROR 5\n";exit} + "home" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/utils/join.exp b/test/utils/join.exp new file mode 100755 index 000000000..fc94a22c3 --- /dev/null +++ b/test/utils/join.exp @@ -0,0 +1,42 @@ +#!/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=svntesting\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --join=svntesting;pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Switching to pid" +} +sleep 1 + + +spawn $env(SHELL) +send -- "firejail --shutdown=svntesting;pwd\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "home" +} +sleep 1 + +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "svntesting" {puts "TESTING ERROR 5\n";exit} + "home" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/utils/join2.exp b/test/utils/join2.exp new file mode 100755 index 000000000..749e8900f --- /dev/null +++ b/test/utils/join2.exp @@ -0,0 +1,42 @@ +#!/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=\"svn testing\"\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --join=\"svn testing\";pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Switching to pid" +} +sleep 1 + + +spawn $env(SHELL) +send -- "firejail --shutdown=\"svn testing\";pwd\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "home" +} +sleep 1 + +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "svn testing" {puts "TESTING ERROR 5\n";exit} + "home" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/utils/join3.exp b/test/utils/join3.exp new file mode 100755 index 000000000..0a686bc36 --- /dev/null +++ b/test/utils/join3.exp @@ -0,0 +1,42 @@ +#!/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=svn\\ testing\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --join=svn\\ testing;pwd\r" +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "Switching to pid" +} +sleep 1 + + +spawn $env(SHELL) +send -- "firejail --shutdown=svn\\ testing;pwd\r" +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "home" +} +sleep 1 + +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "svn testing" {puts "TESTING ERROR 5\n";exit} + "home" +} +sleep 1 + +puts "\nall done\n" diff --git a/test/utils/name.profile b/test/utils/name.profile new file mode 100644 index 000000000..1aa9f2d64 --- /dev/null +++ b/test/utils/name.profile @@ -0,0 +1 @@ +name jointesting diff --git a/test/utils/shutdown.exp b/test/utils/shutdown.exp new file mode 100755 index 000000000..135f42d28 --- /dev/null +++ b/test/utils/shutdown.exp @@ -0,0 +1,33 @@ +#!/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=shutdowntesting\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 3 + +spawn $env(SHELL) +send -- "firejail --shutdown=shutdowntesting;pwd\r" +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "home" +} +sleep 1 + +send -- "firejail --list;pwd\r" +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "shutdowntesting" {puts "TESTING ERROR 6\n";exit} + "home" +} +sleep 1 + +puts "\nalldone\n" diff --git a/test/utils/shutdown2.exp b/test/utils/shutdown2.exp new file mode 100755 index 000000000..7857b919c --- /dev/null +++ b/test/utils/shutdown2.exp @@ -0,0 +1,45 @@ +#!/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 + +set firstspawn $spawn_id + +send -- "firejail --name=shutdowntesting ./catchsignal.sh\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --shutdown=shutdowntesting\r" + +set spawn_id $firstspawn +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "1" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "2" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "3" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "4" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "5" +} +sleep 1 + +puts "\nalldone\n" diff --git a/test/utils/shutdown3.exp b/test/utils/shutdown3.exp new file mode 100755 index 000000000..02b68c4ce --- /dev/null +++ b/test/utils/shutdown3.exp @@ -0,0 +1,65 @@ +#!/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 + +set firstspawn $spawn_id + +send -- "firejail --name=shutdowntesting ./catchsignal-master.sh\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --shutdown=shutdowntesting\r" + +set spawn_id $firstspawn +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "1" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "1" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "2" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "2" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "3" +} +expect { + timeout {puts "TESTING ERROR 6\n";exit} + "3" +} +expect { + timeout {puts "TESTING ERROR 7\n";exit} + "4" +} +expect { + timeout {puts "TESTING ERROR 8\n";exit} + "4" +} +expect { + timeout {puts "TESTING ERROR 9\n";exit} + "5" +} +expect { + timeout {puts "TESTING ERROR 10\n";exit} + "5" +} +sleep 1 + +puts "\nalldone\n" diff --git a/test/utils/shutdown4.exp b/test/utils/shutdown4.exp new file mode 100755 index 000000000..613f3fbc8 --- /dev/null +++ b/test/utils/shutdown4.exp @@ -0,0 +1,69 @@ +#!/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 + +set firstspawn $spawn_id + +send -- "firejail --name=shutdowntesting ./catchsignal2.sh\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +sleep 2 + +spawn $env(SHELL) +send -- "firejail --shutdown=shutdowntesting\r" + +set spawn_id $firstspawn +expect { + timeout {puts "TESTING ERROR 1\n";exit} + "1" +} +expect { + timeout {puts "TESTING ERROR 2\n";exit} + "2" +} +expect { + timeout {puts "TESTING ERROR 3\n";exit} + "3" +} +expect { + timeout {puts "TESTING ERROR 4\n";exit} + "4" +} +expect { + timeout {puts "TESTING ERROR 5\n";exit} + "5" +} +expect { + timeout {puts "TESTING ERROR 10\n";exit} + "10" +} +expect { + timeout {puts "TESTING ERROR 20\n";exit} + "20" +} +expect { + timeout {puts "TESTING ERROR 30\n";exit} + "30" +} +expect { + timeout {puts "TESTING ERROR 40\n";exit} + "40" +} +expect { + timeout {puts "TESTING ERROR 50\n";exit} + "50" +} +expect { + timeout {puts "TESTING ERROR 60\n";exit} + "Killed" +} +sleep 1 + +puts "\nalldone\n" diff --git a/test/utils/utils.sh b/test/utils/utils.sh index 02aaa57c0..a40845a5f 100755 --- a/test/utils/utils.sh +++ b/test/utils/utils.sh @@ -40,3 +40,27 @@ echo "TESTING: seccomp.print (test/utils/seccomp-print.exp)" echo "TESTING: protocol.print (test/utils/protocol-print.exp)" ./protocol-print.exp +echo "TESTING: shutdown (test/utils/shutdown.exp)" +./shutdown.exp + +echo "TESTING: shutdown2 (test/utils/shutdown2.exp)" +./shutdown2.exp + +echo "TESTING: shutdown3 (test/utils/shutdown3.exp)" +./shutdown3.exp + +echo "TESTING: shutdown4 (test/utils/shutdown4.exp)" +./shutdown4.exp + +echo "TESTING: join test/utils/(join.exp)" +./join.exp + +echo "TESTING: join2 test/utils/(join2.exp)" +.join2.exp + +echo "TESTING: join3 (test/utils/join3.exp)" +./join3.exp + +echo "TESTING: join profile (test/utils/join-profile.exp)" +./join-profile.exp + -- cgit v1.2.3-54-g00ecf