0001
0002
0003
0004
0005
0006
0007 set -e
0008
0009 setup() {
0010
0011 tc qdisc add dev lo root netem delay 1ms
0012
0013
0014 modprobe ifb
0015 ip link add ifb_netem0 type ifb
0016 ip link set dev ifb_netem0 up
0017 tc qdisc add dev ifb_netem0 root netem delay 2ms
0018
0019
0020 tc qdisc add dev lo handle ffff: ingress
0021 tc filter add dev lo parent ffff: \
0022 u32 match mark 0 0xffff \
0023 action mirred egress redirect dev ifb_netem0
0024 }
0025
0026 run_test_v4v6() {
0027
0028
0029 local -r args="$@ -v 1000 -V 6000"
0030
0031 ./txtimestamp ${args} -4 -L 127.0.0.1
0032 ./txtimestamp ${args} -6 -L ::1
0033 }
0034
0035 run_test_tcpudpraw() {
0036 local -r args=$@
0037
0038 run_test_v4v6 ${args}
0039 run_test_v4v6 ${args} -u
0040 run_test_v4v6 ${args} -r
0041 run_test_v4v6 ${args} -R
0042 run_test_v4v6 ${args} -P
0043 }
0044
0045 run_test_all() {
0046 setup
0047 run_test_tcpudpraw
0048 run_test_tcpudpraw -C
0049 run_test_tcpudpraw -n
0050 echo "OK. All tests passed"
0051 }
0052
0053 run_test_one() {
0054 setup
0055 ./txtimestamp $@
0056 }
0057
0058 usage() {
0059 echo "Usage: $0 [ -r | --run ] <txtimestamp args> | [ -h | --help ]"
0060 echo " (no args) Run all tests"
0061 echo " -r|--run Run an individual test with arguments"
0062 echo " -h|--help Help"
0063 }
0064
0065 main() {
0066 if [[ $
0067 run_test_all
0068 else
0069 if [[ "$1" = "-r" || "$1" == "--run" ]]; then
0070 shift
0071 run_test_one $@
0072 else
0073 usage
0074 fi
0075 fi
0076 }
0077
0078 if [[ -z "$(ip netns identify)" ]]; then
0079 ./in_netns.sh $0 $@
0080 else
0081 main $@
0082 fi