summaryrefslogtreecommitdiffstats
path: root/test/sys_req/set_system_parameters.sh
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2017-09-20 08:26:30 +0200
committerFlorin Coras <florin.coras@gmail.com>2018-02-01 23:41:17 +0000
commit75e7d1301475d49311d14e202936c62df0c07d10 (patch)
tree1a7e1d211cc97352f093a0207e6c94952e39e611 /test/sys_req/set_system_parameters.sh
parent2b9453c55a7294d8eedf126d616a608c32be0e36 (diff)
IPv4/6 reassembly
Change-Id: Ic5dcadd13c88b8a5e7896dab82404509c081614a Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/sys_req/set_system_parameters.sh')
-rwxr-xr-xtest/sys_req/set_system_parameters.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/sys_req/set_system_parameters.sh b/test/sys_req/set_system_parameters.sh
new file mode 100755
index 00000000000..533a02edbaa
--- /dev/null
+++ b/test/sys_req/set_system_parameters.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+file="$1"
+
+usage(){
+ echo "Usage: $0 <requirements file>"
+}
+
+if [ "$file" == "" ]
+then
+ echo "Invalid parameters specified."
+ usage
+ exit 1
+fi
+
+if [ ! -f $file ]
+then
+ echo "File '$file' does not exist."
+ usage
+ exit 1
+fi
+
+cat $file | grep -v -e '^#.*$' | grep -v -e '^ *$' | while read line
+do
+ value_file=`echo $line | awk '{print $1}'`
+ operator=`echo $line | awk '{print $2}'`
+ value=`echo $line | awk '{print $3}'`
+ set_value=`echo $line | awk '{print $4}'`
+ if [[ "$value_file" == "" || "$operator" == "" || "$value" == "" || "$set_value" == "" ]]
+ then
+ echo "Syntax error in requirements file."
+ exit 1
+ fi
+ current_value=`cat $value_file`
+ if test "$current_value" $operator "$value"
+ then
+ if test "$V" = "2"
+ then
+ echo "Requirement '$value_file $operator $value' satisfied."
+ fi
+ else
+ echo "Requirement '$value_file $operator $value' not satisfied."
+ echo "Writing '$set_value' to '$value_file'."
+ echo "$set_value" | tee "$value_file" > /dev/null
+ if ! test "`cat $value_file`" = "$set_value"
+ then
+ echo "Repeating the write using sudo..."
+ echo "$set_value" | sudo -n tee "$value_file" > /dev/null
+ if ! test "`cat $value_file`" = "$set_value"
+ then
+ echo "Couldn't set the required value. Is that value allowed? Is sudo working?"
+ exit 1
+ fi
+ fi
+ echo "Succesfully wrote '$set_value' to '$value_file'."
+ fi
+done