• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3###############################################################################
4#                                                                             #
5# Copyright (c) 2010 FUJITSU LIMITED                                          #
6#                                                                             #
7# This program is free software; you can redistribute it and/or modify it     #
8# under the terms of the GNU General Public License as published by the Free  #
9# Software Foundation; either version 2 of the License, or (at your option)   #
10# any later version.                                                          #
11#                                                                             #
12# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
13#                                                                             #
14###############################################################################
15
16. test.sh
17
18LOOP=200
19
20while true; do
21	j=0
22	while [ $j -lt $LOOP ]; do
23		trace_options="$(ls $TRACING_PATH/options/)"
24		# enable the nop_test_refuse can cause an
25		# 'write error: Invalid argument'. So don't test it.
26		trace_options="$(echo $trace_options | sed 's/test_nop_refuse//')"
27		nr_trace_options=$(echo "${trace_options}" | wc -w)
28
29		option_index=$(tst_random 1 $nr_trace_options)
30		option=$(echo "$trace_options" | awk "{print \$$option_index}")
31		i=0
32		while [ $i -lt $nr_trace_options ]; do
33			n=$(tst_random 0 1)
34			opt_f="$TRACING_PATH"/options/$option
35			ret_val=0
36			if [ $n -eq 0 ]; then
37				operation="setup"
38			else
39				operation="clear"
40			fi
41			# On old kernel, some trace option dirs
42			# won't be made if the option has nothing
43			# to do with the current tracer. But on newer
44			# kernel(4.4-rc1), all option dirs will be made.
45			# So here check it to avoid 'Permision denied'
46			if [ -f $opt_f ]; then
47				echo $n > $opt_f
48				ret_val=$?
49			fi
50
51			if [ $ret_val -ne 0 ]; then
52				tst_resm TFAIL "$0: $operation trace option $option failed"
53			fi
54			i=$((i + 1))
55		done
56		j=$((j + 1))
57	done
58done
59