10f66f451Sopenharmony_ci#!/bin/bash 20f66f451Sopenharmony_ci 30f66f451Sopenharmony_ci[ -f testing.sh ] && . testing.sh 40f66f451Sopenharmony_ci 50f66f451Sopenharmony_ci#testing "name" "command" "result" "infile" "stdin" 60f66f451Sopenharmony_ci 70f66f451Sopenharmony_citestcmd '0 args' '; echo $?' '1\n' '' '' 80f66f451Sopenharmony_citestcmd '1 arg' '== ; echo $?' '0\n' '' '' 90f66f451Sopenharmony_citestcmd '2 args' '-e == ; echo $?' '1\n' '' '' 100f66f451Sopenharmony_citestcmd '3 args' '-e == -e ; echo $?' '0\n' '' '' 110f66f451Sopenharmony_citestcmd '' '\( == \) ; echo $?' '1\n' '' '' 120f66f451Sopenharmony_citestcmd '' '\( == \( ; echo $?' '0\n' '' '' 130f66f451Sopenharmony_ci 140f66f451Sopenharmony_ci# TODO: Should also have device and socket files 150f66f451Sopenharmony_ci 160f66f451Sopenharmony_cimkdir d 170f66f451Sopenharmony_citouch f 180f66f451Sopenharmony_ciln -s /dev/null L 190f66f451Sopenharmony_ciecho nonempty > s 200f66f451Sopenharmony_cimkfifo p 210f66f451Sopenharmony_ci 220f66f451Sopenharmony_citype_test() 230f66f451Sopenharmony_ci{ 240f66f451Sopenharmony_ci for i in d f L s p n 250f66f451Sopenharmony_ci do 260f66f451Sopenharmony_ci "$C" $* $i && echo -n $i 270f66f451Sopenharmony_ci done 280f66f451Sopenharmony_ci} 290f66f451Sopenharmony_ci 300f66f451Sopenharmony_citesting "-b" "type_test -b" "" "" "" 310f66f451Sopenharmony_citesting "-c" "type_test -c" "L" "" "" 320f66f451Sopenharmony_citesting "-d" "type_test -d" "d" "" "" 330f66f451Sopenharmony_citesting "-f" "type_test -f" "fs" "" "" 340f66f451Sopenharmony_citesting "-h" "type_test -h" "L" "" "" 350f66f451Sopenharmony_citesting "-L" "type_test -L" "L" "" "" 360f66f451Sopenharmony_citesting "-s" "type_test -s" "ds" "" "" 370f66f451Sopenharmony_citesting "-S" "type_test -S" "" "" "" 380f66f451Sopenharmony_citesting "-p" "type_test -p" "p" "" "" 390f66f451Sopenharmony_citesting "-e" "type_test -e" "dfLsp" "" "" 400f66f451Sopenharmony_citesting "! -e" 'type_test ! -e' "n" "" "" 410f66f451Sopenharmony_ci 420f66f451Sopenharmony_cirm f L s p 430f66f451Sopenharmony_cirmdir d 440f66f451Sopenharmony_ci 450f66f451Sopenharmony_ci# TODO: Test rwx gu t 460f66f451Sopenharmony_ci 470f66f451Sopenharmony_citestcmd "" "'' || echo yes" "yes\n" "" "" 480f66f451Sopenharmony_citestcmd "" "a && echo yes" "yes\n" "" "" 490f66f451Sopenharmony_citestcmd "-n" "-n '' || echo yes" "yes\n" "" "" 500f66f451Sopenharmony_citestcmd "-n2" "-n a && echo yes" "yes\n" "" "" 510f66f451Sopenharmony_citestcmd "-z" "-z '' && echo yes" "yes\n" "" "" 520f66f451Sopenharmony_citestcmd "-z2" "-z a || echo yes" "yes\n" "" "" 530f66f451Sopenharmony_citestcmd "" "a = b || echo yes" "yes\n" "" "" 540f66f451Sopenharmony_citestcmd "" "'' = '' && echo yes" "yes\n" "" "" 550f66f451Sopenharmony_citestcmd "a != b" "a != b && echo yes" "yes\n" "" "" 560f66f451Sopenharmony_citestcmd "a != b" "a != a || echo yes" "yes\n" "" "" 570f66f451Sopenharmony_ci 580f66f451Sopenharmony_ciarith_test() 590f66f451Sopenharmony_ci{ 600f66f451Sopenharmony_ci $C -1 $1 1 && echo -n l 610f66f451Sopenharmony_ci $C 0 $1 0 && echo -n e 620f66f451Sopenharmony_ci $C -3 $1 -5 && echo -n g 630f66f451Sopenharmony_ci} 640f66f451Sopenharmony_ci 650f66f451Sopenharmony_citesting "-eq" "arith_test -eq" "e" "" "" 660f66f451Sopenharmony_citesting "-ne" "arith_test -ne" "lg" "" "" 670f66f451Sopenharmony_citesting "-gt" "arith_test -gt" "g" "" "" 680f66f451Sopenharmony_citesting "-ge" "arith_test -ge" "eg" "" "" 690f66f451Sopenharmony_citesting "-lt" "arith_test -lt" "l" "" "" 700f66f451Sopenharmony_citesting "-le" "arith_test -le" "le" "" "" 710f66f451Sopenharmony_ci 720f66f451Sopenharmony_ci# test ! = -o a 730f66f451Sopenharmony_ci# test ! \( = -o a \) 740f66f451Sopenharmony_ci# test \( ! = \) -o a 750f66f451Sopenharmony_ci# test \( \) 760f66f451Sopenharmony_ci 770f66f451Sopenharmony_ci#testing "" "[ -a -eq -a ] && echo yes" "yes\n" "" "" 780f66f451Sopenharmony_ci 790f66f451Sopenharmony_ci# -e == -a 800f66f451Sopenharmony_ci# -e == -a -o -d != -o 810f66f451Sopenharmony_ci# \( "x" \) -a \) == \) 820f66f451Sopenharmony_ci# \( ! ! ! -e \) \) 830f66f451Sopenharmony_ci 840f66f451Sopenharmony_ci# // () -a (() -a () -o ()) -o () 850f66f451Sopenharmony_ci# // x -a ( x -o x ) -a x 860f66f451Sopenharmony_ci# // x -o ( x -a x ) -a x -o x 870f66f451Sopenharmony_ci 880f66f451Sopenharmony_ci# trailing ! and ( 89