diff --git a/.ci/prfilter b/.ci/prfilter index 78eea80c..73d4396e 100755 --- a/.ci/prfilter +++ b/.ci/prfilter @@ -14,7 +14,6 @@ THE_BIG_LIST_OF_NAUGHTY_FILES = list(map(pathlib.Path, [ # only when they are a part of the current pull request. # - # for pylint 'Documentation/conf.py', 'LibOS/shim/test/ltp/contrib/conf_lint.py', 'LibOS/shim/test/ltp/contrib/conf_merge.py', @@ -37,17 +36,6 @@ THE_BIG_LIST_OF_NAUGHTY_FILES = list(map(pathlib.Path, [ 'Pal/src/host/Linux/pal-gdb.py', 'Scripts/regression.py', 'Tools', - - # for shellcheck - 'Examples/bash/scripts/bash_test.sh', - 'Examples/common_tools/benchmark-http.sh', - 'Examples/python-simple/run-tests.sh', - 'LibOS/shim/test/native', - 'Pal/src/host/Linux-SGX/debugger/gdb', - 'Scripts/list-all-graphene.sh', - 'Scripts/memusg', - '.ci/run-pylint', - '.ci/run-shellcheck', ])) def get_diff_ranges(ref=DEFAULT_REF): diff --git a/.ci/run-shellcheck b/.ci/run-shellcheck index 82d4dbb6..a8b4df2c 100755 --- a/.ci/run-shellcheck +++ b/.ci/run-shellcheck @@ -8,7 +8,6 @@ shellcheck "$@" \ Examples/bash/scripts/bash_test.sh \ Examples/common_tools/benchmark-http.sh \ Examples/python-simple/run-tests.sh \ - LibOS/shim/test/native/*.sh \ Pal/src/host/Linux-SGX/debugger/gdb \ Runtime/pal_loader \ Scripts/clean-check \ @@ -16,7 +15,5 @@ shellcheck "$@" \ Scripts/clean-check-test-copy \ Scripts/download \ Scripts/gitignore-test \ - Scripts/list-all-graphene.sh \ - Scripts/memusg \ .ci/run-pylint \ .ci/run-shellcheck diff --git a/Examples/bash/scripts/bash_test.sh b/Examples/bash/scripts/bash_test.sh index e3396596..e8687099 100755 --- a/Examples/bash/scripts/bash_test.sh +++ b/Examples/bash/scripts/bash_test.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash times=$1 -[ $times -gt 0 2> /dev/null ] || times=300 +[ "$times" -gt 0 ] 2>/dev/null || times=300 -for (( c=1; c<=$times; c++ )) +for (( c=1; c<=times; c++ )) do echo "hello $c" cp somefile testdir/somefile diff --git a/Examples/common_tools/benchmark-http.sh b/Examples/common_tools/benchmark-http.sh index 1e2c9761..fb5340f9 100755 --- a/Examples/common_tools/benchmark-http.sh +++ b/Examples/common_tools/benchmark-http.sh @@ -16,16 +16,16 @@ CONCURRENCY_LIST=${CONCURRENCY_LIST:-"1 2 4 8 16 32 64 128 256"} OPTIONS="-k" RESULT=result-$(date +%y%m%d-%H%M%S) -touch $RESULT +touch "$RESULT" RUN=0 -while [ $RUN -lt $LOOP ] +while [ $RUN -lt "$LOOP" ] do for CONCURRENCY in $CONCURRENCY_LIST do rm -f OUTPUT echo "ab $OPTIONS -n $REQUESTS -c $CONCURRENCY $DOWNLOAD_HOST/$DOWNLOAD_FILE" - ab $OPTIONS -n $REQUESTS -c $CONCURRENCY $DOWNLOAD_HOST/$DOWNLOAD_FILE > OUTPUT || exit $? + ab $OPTIONS -n $REQUESTS -c "$CONCURRENCY" "$DOWNLOAD_HOST/$DOWNLOAD_FILE" > OUTPUT || exit $? sleep 5 @@ -36,14 +36,14 @@ do LATENCIES[$CONCURRENCY]="${LATENCIES[$CONCURRENCY]} $LATENCY" echo "concurrency=$CONCURRENCY, throughput=$THROUGHPUT, latency=$LATENCY, failed=$FAILED" done - RUN=$(expr $RUN + 1) + (( RUN++ )) done for CONCURRENCY in $CONCURRENCY_LIST do - THROUGHPUT=$(echo ${THROUGHPUTS[$CONCURRENCY]} | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}') - LATENCY=$(echo ${LATENCIES[$CONCURRENCY]} | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}') - echo "$THROUGHPUT,$LATENCY" >> $RESULT + THROUGHPUT=$(echo "${THROUGHPUTS[$CONCURRENCY]}" | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}') + LATENCY=$(echo "${LATENCIES[$CONCURRENCY]}" | tr " " "\n" | sort -n | awk '{a[NR]=$0}END{if(NR%2==1)print a[int(NR/2)+1];else print(a[NR/2-1]+a[NR/2])/2}') + echo "$THROUGHPUT,$LATENCY" >> "$RESULT" done echo "Result file: $RESULT" diff --git a/Examples/python-simple/run-tests.sh b/Examples/python-simple/run-tests.sh index 8db46bfe..97436536 100755 --- a/Examples/python-simple/run-tests.sh +++ b/Examples/python-simple/run-tests.sh @@ -24,5 +24,5 @@ echo -e "\n\nRunning HTTP client test-http.py:" wget -q http://localhost:8005/ -O OUTPUT2 echo >> OUTPUT2 # include newline since wget doesn't add it diff -q OUTPUT1 OUTPUT2 && echo "[ Success 3/3 ]" -kill `cat server.PID` +kill "$(cat server.PID)" rm -f OUTPUT1 OUTPUT2 server.PID diff --git a/Jenkinsfiles/Linux b/Jenkinsfiles/Linux index 98daad07..227448ce 100644 --- a/Jenkinsfiles/Linux +++ b/Jenkinsfiles/Linux @@ -8,8 +8,7 @@ pipeline { stage('Lint') { steps { sh ''' - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-18.04 b/Jenkinsfiles/Linux-18.04 index c5b35cc1..f8878fa9 100644 --- a/Jenkinsfiles/Linux-18.04 +++ b/Jenkinsfiles/Linux-18.04 @@ -11,8 +11,7 @@ pipeline { ./.ci/run-pylint -f text || : ./.ci/run-pylint -f json | ./.ci/prfilter - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-Debug b/Jenkinsfiles/Linux-Debug index 52f78083..9d84c5af 100644 --- a/Jenkinsfiles/Linux-Debug +++ b/Jenkinsfiles/Linux-Debug @@ -8,8 +8,7 @@ pipeline { stage('Lint') { steps { sh ''' - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-Debug-18.04 b/Jenkinsfiles/Linux-Debug-18.04 index 4cbbac51..42568048 100644 --- a/Jenkinsfiles/Linux-Debug-18.04 +++ b/Jenkinsfiles/Linux-Debug-18.04 @@ -11,8 +11,7 @@ pipeline { ./.ci/run-pylint -f text || : ./.ci/run-pylint -f json | ./.ci/prfilter - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-SGX b/Jenkinsfiles/Linux-SGX index bd9914c0..b7abc812 100644 --- a/Jenkinsfiles/Linux-SGX +++ b/Jenkinsfiles/Linux-SGX @@ -9,8 +9,7 @@ pipeline { stage('Lint') { steps { sh ''' - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-SGX-18.04 b/Jenkinsfiles/Linux-SGX-18.04 index 2d888988..853ac65b 100644 --- a/Jenkinsfiles/Linux-SGX-18.04 +++ b/Jenkinsfiles/Linux-SGX-18.04 @@ -12,8 +12,7 @@ pipeline { ./.ci/run-pylint -f text || : ./.ci/run-pylint -f json | ./.ci/prfilter - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-SGX-18.04-apps b/Jenkinsfiles/Linux-SGX-18.04-apps index 4f36b436..52c5c70a 100644 --- a/Jenkinsfiles/Linux-SGX-18.04-apps +++ b/Jenkinsfiles/Linux-SGX-18.04-apps @@ -12,8 +12,7 @@ pipeline { ./.ci/run-pylint -f text || : ./.ci/run-pylint -f json | ./.ci/prfilter - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/Jenkinsfiles/Linux-SGX-apps b/Jenkinsfiles/Linux-SGX-apps index eeb3e573..1e04336a 100644 --- a/Jenkinsfiles/Linux-SGX-apps +++ b/Jenkinsfiles/Linux-SGX-apps @@ -9,8 +9,7 @@ pipeline { stage('Lint') { steps { sh ''' - ./.ci/run-shellcheck || : - ./.ci/run-shellcheck -f json | ./.ci/prfilter + ./.ci/run-shellcheck ''' } } diff --git a/LibOS/shim/test/native/Makefile b/LibOS/shim/test/native/Makefile index e1e16428..8706ba10 100644 --- a/LibOS/shim/test/native/Makefile +++ b/LibOS/shim/test/native/Makefile @@ -34,7 +34,6 @@ c_executables = \ pipe_latency \ readdir \ rename \ - script \ sem \ sleep \ socketpair \ @@ -54,7 +53,6 @@ manifests = \ manifest \ exec_fork.manifest \ ls.manifest \ - script.manifest \ static.manifest exec_target = \ diff --git a/LibOS/shim/test/native/script.c b/LibOS/shim/test/native/script.c deleted file mode 100644 index 98c55acb..00000000 --- a/LibOS/shim/test/native/script.c +++ /dev/null @@ -1,17 +0,0 @@ -#define _XOPEN_SOURCE 700 -#include -#include -#include -#include - -int main(int argc, const char** argv, const char** envp) { - int newfd = dup(1); - char fd_argv[4]; - snprintf(fd_argv, 4, "%d", newfd); - char* const new_argv[] = {"./script1.sh", fd_argv, NULL}; - - setenv("IN_EXECVE", "1", 1); - - execv(new_argv[0], new_argv); - return 1; -} diff --git a/LibOS/shim/test/native/script.manifest.template b/LibOS/shim/test/native/script.manifest.template deleted file mode 100644 index 82b00ed2..00000000 --- a/LibOS/shim/test/native/script.manifest.template +++ /dev/null @@ -1,28 +0,0 @@ -loader.preload = file:$(SHIMPATH) -loader.env.LD_LIBRARY_PATH = /lib -loader.debug_type = inline -loader.syscall_symbol = syscalldb -loader.insecure__use_cmdline_argv = 1 - -fs.mount.lib.type = chroot -fs.mount.lib.path = /lib -fs.mount.lib.uri = file:$(LIBCDIR) - -fs.mount.bin.type = chroot -fs.mount.bin.path = /bin -fs.mount.bin.uri = file:/bin - -sys.brk.max_size = 32M -sys.stack.size = 4M - -sgx.trusted_files.ld = file:$(LIBCDIR)/ld-linux-x86-64.so.2 -sgx.trusted_files.libc = file:$(LIBCDIR)/libc.so.6 -sgx.trusted_files.libdl = file:$(LIBCDIR)/libdl.so.2 -sgx.trusted_files.libm = file:$(LIBCDIR)/libm.so.6 -sgx.trusted_files.libpthread = file:$(LIBCDIR)/libpthread.so.0 - -sgx.trusted_files.script1_sh = file:script1.sh -sgx.trusted_files.script2_sh = file:script2.sh -sgx.trusted_files.script3_sh = file:script3.sh -sgx.trusted_files.helloworld = file:helloworld -sgx.trusted_children.helloworld = file:helloworld.sig diff --git a/LibOS/shim/test/native/script1.sh b/LibOS/shim/test/native/script1.sh deleted file mode 100644 index b479d977..00000000 --- a/LibOS/shim/test/native/script1.sh +++ /dev/null @@ -1 +0,0 @@ -#!/script2.sh diff --git a/LibOS/shim/test/native/script2.sh b/LibOS/shim/test/native/script2.sh deleted file mode 100644 index b0b41da9..00000000 --- a/LibOS/shim/test/native/script2.sh +++ /dev/null @@ -1 +0,0 @@ -#!/script3.sh diff --git a/LibOS/shim/test/native/script3.sh b/LibOS/shim/test/native/script3.sh deleted file mode 100644 index 46a44c0a..00000000 --- a/LibOS/shim/test/native/script3.sh +++ /dev/null @@ -1 +0,0 @@ -#!/helloworld diff --git a/Pal/src/host/Linux-SGX/debugger/gdb b/Pal/src/host/Linux-SGX/debugger/gdb index 6209d084..77e6c235 100755 --- a/Pal/src/host/Linux-SGX/debugger/gdb +++ b/Pal/src/host/Linux-SGX/debugger/gdb @@ -1,6 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash -DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]})) +DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" GDB_SCRIPT=$DIR/pal-gdb.py GDB_SO=$DIR/sgx_gdb.so if [ -z "$INSIDE_EMACS" ]; then diff --git a/Runtime/pal_loader b/Runtime/pal_loader index 8cde4470..9e483929 100755 --- a/Runtime/pal_loader +++ b/Runtime/pal_loader @@ -72,10 +72,6 @@ if [ "$PERF" == "1" ]; then PREFIX=(perf stat) fi -if [ "$MEMUSG" == "1" ]; then - PREFIX=("$RUNTIME_DIR/../Scripts/memusg") -fi - while [ "$1" != "" ]; do if [ "$MANIFEST" == "" ]; then diff --git a/Scripts/list-all-graphene.sh b/Scripts/list-all-graphene.sh deleted file mode 100755 index 0b222a7c..00000000 --- a/Scripts/list-all-graphene.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash - -ID=`id -u` -PGIDS=`ps -a -o pgid,command | tail -n +2 | \ - awk "{ if (\\\$2 ~ /\\/pal\$/ ) print \\\$1 }" | uniq` - -NONE=1 -for PGID in $PGIDS -do - NONE=0 - ps -p $PGID -o pid,args 2> /dev/null | tail -n +2 -done - -if [ "$NONE" = "1" ]; then - echo "no graphene instance" - exit 0 -fi - -echo -n "choose intance(s): " -read SELECT_PGIDS - -DO_KILL=0 -for CMD in $SELECT_PGIDS -do - if [ "$CMD" = "kill" ]; then - SELECT_PGIDS=${SELECT_PGIDS:4} - DO_KILL=1 - fi - break -done - -do_list() -{ - PGID=$1 - echo "instance $PGID:" - PIDS=`ps -a -o pgid,pid --sort=start_time 2> /dev/null | tail -n +2 | \ - awk "{ if (\\\$1 == $PGID) print \\\$2 }"` - - CNT=1 - for PID in $PIDS - do - STAT=`ps -a -p $PID -o stat | tail -n +2` - if [[ $STAT == Z* ]]; then - printf " %3d: process %5d (DEAD):" $CNT $PID - else - printf " %3d: process %5d :" $CNT $PID - fi - for TASK in /proc/$PID/task/* - do - printf " %5d" ${TASK##*/} - done - echo - CNT=`expr $CNT + 1` - done -} - -do_kill() -{ - PGID=$1 - PIDS=`ps -a -o pgid,pid 2> /dev/null | tail -n +2 | \ - awk "{ if (\\\$1 == $PGID) print \\\$2 }"` - kill -9 $PGID $PIDS -} - -NONE=1 -for PGID in $SELECT_PGIDS -do - if [ "$DO_KILL" = "1" ]; then - do_kill $PGID - else - do_list $PGID - fi - NONE=0 -done - -if [ "$NONE" = "1" ]; then - for PGID in $PGIDS - do - if [ "$DO_KILL" = "1" ]; then - do_kill $PGID - else - do_list $PGID - fi - done -fi diff --git a/Scripts/memusg b/Scripts/memusg deleted file mode 100755 index e351431e..00000000 --- a/Scripts/memusg +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# memusg -- Measure memory usage of processes -# Usage: memusg COMMAND [ARGS]... -# -# Author: Jaeho Shin -# Created: 2010-08-16 -set -um - -# check input -[ $# -gt 0 ] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; } - -# TODO support more options: peak, footprint, sampling rate, etc. - -pgid=`ps -o pgid= $$` - -command="$@" - -# make sure we're in a separate process group -if [ $pgid = $(ps -o pgid= $(ps -o ppid= $$)) ]; then - cmd= - set -- "$0" "$@" - for a; do cmd+="'${a//"'"/"'\\''"}' "; done - exec bash -i -c "$cmd" -fi - -# detect operating system and prepare measurement -case `uname` in - Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;; - Linux) sizes() { /bin/ps -o rss= -$1; } ;; - *) echo "`uname`: unsupported operating system" >&2; exit 2 ;; -esac - -rm -f "histogram.mem.usg" - -# monitor the memory usage in the background. -( -peak=0 -while sizes=`sizes $pgid` -do - set -- $sizes - sample=$((${@/#/+})) - echo "$sample" >> "histogram.mem.usg" - let peak="sample > peak ? sample : peak" - sleep 0.1 -done -echo "memusg \`$command\`: peak=$peak kiloBytes" >> "peak.mem.usg" -) & -monpid=$! - -echo "running: exec $@" - -# run the given command -exec "$@"