set test "user_string_n_quoted"
if {![installtest_p]} { untested $test; return }
-spawn stap $srcdir/$subdir/user_string_n_quoted.stp -c "echo this_is_a_test > /dev/null"
-expect {
- -timeout 60
- {"this_is_a_"...} { pass $test }
- eof { fail $test }
- timeout {
- fail "$test (timeout)"
- catch { exec kill -INT -- -[exp_pid] }
- }
-}
-
-catch { close }; catch { wait }
+set ::result_string {"this_is_a_test\n"
+"this_is_a_test"
+"this_is_a_tes"
+"this_is_a_test\n"
+"this_is_a_te"...
+"this_is_a_t"...
+"this_is_a_"...
+"this_is_a"...}
+stap_run2 $srcdir/$subdir/$test.stp -c "echo this_is_a_test > /dev/null"
-# Ensure that user_string_n_quoted truncates properly and there's no
-# off-by-one error... PR15617
+# Ensure that user_string_n_quoted truncates properly by input length and
+# there's no off-by-one error (see PR15617). Also ensures that
+# user_string_n2_quoted properly truncates by output length.
+# We avoid using @MAXSTRINGLEN to not have to require -g
probe syscall.write {
if (pid() == target()) {
printf("%s\n", user_string_n_quoted(buf_uaddr, 15))
+ printf("%s\n", user_string_n_quoted(buf_uaddr, 14))
+ printf("%s\n", user_string_n_quoted(buf_uaddr, 13))
+ printf("%s\n", user_string_n2_quoted(buf_uaddr, 99, 18))
+ printf("%s\n", user_string_n2_quoted(buf_uaddr, 99, 17))
+ printf("%s\n", user_string_n2_quoted(buf_uaddr, 99, 16))
+ printf("%s\n", user_string_n2_quoted(buf_uaddr, 99, 15))
+ printf("%s\n", user_string_n2_quoted(buf_uaddr, 99, 14))
exit()
}
}