+
+### KERNEL TESTS
+
+BIN_NAME="test_valid_filt" # Current script name truncated by kernel
+
+# One to one mapping between filters and validators
+
+KERNEL_FILTERS=("intfield" #1
+ "intfield > 1" #2
+ "intfield >= 1" #3
+ "intfield < 2" #4
+ "intfield <= 2" #5
+ "intfield == 1" #6
+ "intfield != 99" #7
+ "!intfield" #8
+ "-intfield" #9
+ "--intfield" #10
+ "+intfield" #11
+ "++intfield" #12
+ "intfield > 1 && longfield > 42" #13
+ "intfield >= 42 && longfield <= 42" #14
+ "intfield < 1 || longfield > 98" #15
+ "(stringfield == \"test\" || intfield != 10) && intfield > 33" #16
+ "intfield < 42.4242424242" #17
+ "\"test\" == \"test\"" #18 #Issue #342
+ "stringfield == \"test\"" #19
+ "stringfield == \"t*\"" #20
+ "stringfield == \"*\"" #21
+ $issue_356_filter #22 #Issue #356
+ "intfield < 0xDEADBEEF" #23
+ "intfield < 0x2" #24
+ "intfield < 02" #25
+ "stringfield2 == \"\\\*\"" #26
+ "1.0 || intfield || 1.0" #27
+ "1 < intfield" #28
+ "\$ctx.vtid == 0" #29
+ "\$ctx.vtid != 0" #30
+ "0 == \$ctx.vtid" #31
+ "0 != \$ctx.vtid" #32
+ "\$ctx.vpid == 0" #33
+ "\$ctx.vpid != 0" #34
+ "0 == \$ctx.vpid" #35
+ "0 != \$ctx.vpid" #36
+ "\$ctx.procname != \"$BIN_NAME\"" #37
+ "\$ctx.procname == \"$BIN_NAME\"" #38
+ "\"$BIN_NAME\" != \$ctx.procname" #39
+ "\"$BIN_NAME\" == \$ctx.procname" #40
+ "\$ctx.procname != \"$BIN_NAME*\"" #41
+ "\$ctx.procname == \"$BIN_NAME*\"" #42
+ "\"$BIN_NAME*\" != \$ctx.procname" #43
+ "\"$BIN_NAME*\" == \$ctx.procname" #44
+ "\$ctx.procname != \"*\"" #45
+ "\$ctx.procname == \"*\"" #46
+ "\"*\" != \$ctx.procname" #47
+ "\"*\" == \$ctx.procname" #48
+ "!a.f.d" #49
+ "a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a" #50
+ "\$ctx.vtid.blah == 0" #51
+ "asdf.asdfsd.sadf < 4" #52
+ "0 == \$ctx.vtid.blah" #53
+ "\$ctx.44 == 0" #54
+ "0 == \$ctx.44" #55
+)
+
+KERNEL_FILTER_COUNT=${#KERNEL_FILTERS[@]}
+
+KERNEL_VALIDATOR=("validator_intfield" #1
+ "validator_intfield_gt" #2
+ "validator_intfield_ge" #3
+ "validator_intfield_lt" #4
+ "validator_intfield_le" #5
+ "validator_intfield_eq" #6
+ "validator_intfield_ne" #7
+ "validator_intfield_not" #8
+ "validator_intfield" #9
+ "validator_intfield" #10
+ "validator_intfield" #11
+ "validator_intfield" #12
+ "validator_intfield_gt_and_longfield_gt" #13
+ "validator_intfield_ge_and_longfield_le" #14
+ "validator_intfield_lt_or_longfield_gt" #15
+ "validator_mixed_str_or_int_and_int" #16
+ "validator_has_no_event" #17 #Unsupported by kernel
+ "validator_true_statement" #18
+ "validator_true_statement" #19
+ "validator_true_statement" #20
+ "validator_true_statement" #21
+ "validator_intfield" #22
+ "validator_true_statement" #23
+ "validator_intfield_lt" #24
+ "validator_intfield_lt" #25
+ "validator_true_statement" #26
+ "validator_has_no_event" #27 #Unsupported by kernel
+ "validator_intfield_gt" #28
+ "validator_has_no_event" #29
+ "validator_has_events" #30
+ "validator_has_no_event" #31
+ "validator_has_events" #32
+ "validator_has_no_event" #33
+ "validator_has_events" #34
+ "validator_has_no_event" #35
+ "validator_has_events" #36
+ "validator_has_no_event" #36
+ "validator_has_events" #37
+ "validator_has_no_event" #38
+ "validator_has_events" #39
+ "validator_has_no_event" #41
+ "validator_has_events" #42
+ "validator_has_no_event" #43
+ "validator_has_events" #44
+ "validator_has_no_event" #45
+ "validator_has_events" #46
+ "validator_has_no_event" #47
+ "validator_has_events" #48
+ "validator_has_no_event" #49
+ "validator_has_no_event" #50
+ "validator_has_no_event" #51
+ "validator_has_no_event" #52
+ "validator_has_no_event" #53
+ "validator_has_no_event" #54
+ "validator_has_no_event" #55
+)
+
+if [ "$(id -u)" == "0" ]; then
+ isroot=1
+else
+ isroot=0
+fi
+
+skip $isroot "Root access is needed. Skipping all kernel valid filter tests." $NUM_KERNEL_TESTS ||
+{
+ diag "Test kernel valid filters"
+
+ KERNEL_CHECK=1
+ modprobe lttng-test
+ i=0
+ while [ "$i" -lt "$KERNEL_FILTER_COUNT" ]; do
+
+ test_valid_filter kernel -k "lttng_test_filter_event" \
+ "${KERNEL_FILTERS[$i]}" "${KERNEL_VALIDATOR[$i]}"
+
+ if [ $? -eq 1 ]; then
+ stop_lttng_sessiond
+ exit 1
+ fi
+
+ let "i++"
+ done
+ rmmod lttng-test
+}
+