| 1 |
# PR 11223. Make sure we can handle large amounts of procfs write data. |
| 2 |
|
| 3 |
set test "PROCFS_WRITE" |
| 4 |
|
| 5 |
if {![installtest_p]} { untested $test; return } |
| 6 |
|
| 7 |
proc proc_write_value { test path value} { |
| 8 |
if [catch {open $path WRONLY} channel] { |
| 9 |
fail "$test $channel" |
| 10 |
} else { |
| 11 |
puts $channel $value |
| 12 |
close $channel |
| 13 |
pass "$test wrote $value" |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
# This test string is ~4224 bytes long (66 lines of 64 chars). The |
| 18 |
# procfs kernel system will use a buffer of 4K. Our string of ~4224 |
| 19 |
# should take around 9 trips through the write function (4224 chars / |
| 20 |
# 512 bytes per systemtap string = ~9 trips). |
| 21 |
# |
| 22 |
# The kernel reuses the 4K buffer for the 9th trip and doesn't null |
| 23 |
# terminate the string. Instead, it tells consumers how many bytes |
| 24 |
# are present. |
| 25 |
# |
| 26 |
# We want to make sure we can handle > 4K worth of data properly. |
| 27 |
set test_string \ |
| 28 |
" 0:12345678901234567890123456789012345678901234567890123456789 |
| 29 |
1:12345678901234567890123456789012345678901234567890123456789 |
| 30 |
2:12345678901234567890123456789012345678901234567890123456789 |
| 31 |
3:12345678901234567890123456789012345678901234567890123456789 |
| 32 |
4:12345678901234567890123456789012345678901234567890123456789 |
| 33 |
5:12345678901234567890123456789012345678901234567890123456789 |
| 34 |
6:12345678901234567890123456789012345678901234567890123456789 |
| 35 |
7:12345678901234567890123456789012345678901234567890123456789 |
| 36 |
8:12345678901234567890123456789012345678901234567890123456789 |
| 37 |
9:12345678901234567890123456789012345678901234567890123456789 |
| 38 |
10:12345678901234567890123456789012345678901234567890123456789 |
| 39 |
11:12345678901234567890123456789012345678901234567890123456789 |
| 40 |
12:12345678901234567890123456789012345678901234567890123456789 |
| 41 |
13:12345678901234567890123456789012345678901234567890123456789 |
| 42 |
14:12345678901234567890123456789012345678901234567890123456789 |
| 43 |
15:12345678901234567890123456789012345678901234567890123456789 |
| 44 |
16:12345678901234567890123456789012345678901234567890123456789 |
| 45 |
17:12345678901234567890123456789012345678901234567890123456789 |
| 46 |
18:12345678901234567890123456789012345678901234567890123456789 |
| 47 |
19:12345678901234567890123456789012345678901234567890123456789 |
| 48 |
20:12345678901234567890123456789012345678901234567890123456789 |
| 49 |
21:12345678901234567890123456789012345678901234567890123456789 |
| 50 |
22:12345678901234567890123456789012345678901234567890123456789 |
| 51 |
23:12345678901234567890123456789012345678901234567890123456789 |
| 52 |
24:12345678901234567890123456789012345678901234567890123456789 |
| 53 |
25:12345678901234567890123456789012345678901234567890123456789 |
| 54 |
26:12345678901234567890123456789012345678901234567890123456789 |
| 55 |
27:12345678901234567890123456789012345678901234567890123456789 |
| 56 |
28:12345678901234567890123456789012345678901234567890123456789 |
| 57 |
29:12345678901234567890123456789012345678901234567890123456789 |
| 58 |
30:12345678901234567890123456789012345678901234567890123456789 |
| 59 |
31:12345678901234567890123456789012345678901234567890123456789 |
| 60 |
32:12345678901234567890123456789012345678901234567890123456789 |
| 61 |
33:12345678901234567890123456789012345678901234567890123456789 |
| 62 |
34:12345678901234567890123456789012345678901234567890123456789 |
| 63 |
35:12345678901234567890123456789012345678901234567890123456789 |
| 64 |
36:12345678901234567890123456789012345678901234567890123456789 |
| 65 |
37:12345678901234567890123456789012345678901234567890123456789 |
| 66 |
38:12345678901234567890123456789012345678901234567890123456789 |
| 67 |
39:12345678901234567890123456789012345678901234567890123456789 |
| 68 |
40:12345678901234567890123456789012345678901234567890123456789 |
| 69 |
41:12345678901234567890123456789012345678901234567890123456789 |
| 70 |
42:12345678901234567890123456789012345678901234567890123456789 |
| 71 |
43:12345678901234567890123456789012345678901234567890123456789 |
| 72 |
44:12345678901234567890123456789012345678901234567890123456789 |
| 73 |
45:12345678901234567890123456789012345678901234567890123456789 |
| 74 |
46:12345678901234567890123456789012345678901234567890123456789 |
| 75 |
47:12345678901234567890123456789012345678901234567890123456789 |
| 76 |
48:12345678901234567890123456789012345678901234567890123456789 |
| 77 |
49:12345678901234567890123456789012345678901234567890123456789 |
| 78 |
50:12345678901234567890123456789012345678901234567890123456789 |
| 79 |
51:12345678901234567890123456789012345678901234567890123456789 |
| 80 |
52:12345678901234567890123456789012345678901234567890123456789 |
| 81 |
53:12345678901234567890123456789012345678901234567890123456789 |
| 82 |
54:12345678901234567890123456789012345678901234567890123456789 |
| 83 |
55:12345678901234567890123456789012345678901234567890123456789 |
| 84 |
56:12345678901234567890123456789012345678901234567890123456789 |
| 85 |
57:12345678901234567890123456789012345678901234567890123456789 |
| 86 |
58:12345678901234567890123456789012345678901234567890123456789 |
| 87 |
59:12345678901234567890123456789012345678901234567890123456789 |
| 88 |
60:12345678901234567890123456789012345678901234567890123456789 |
| 89 |
61:12345678901234567890123456789012345678901234567890123456789 |
| 90 |
62:12345678901234567890123456789012345678901234567890123456789 |
| 91 |
63:12345678901234567890123456789012345678901234567890123456789 |
| 92 |
64:12345678901234567890123456789012345678901234567890123456789 |
| 93 |
65:12345678901234567890123456789012345678901234567890123456789 |
| 94 |
66:12345678901234567890123456789012345678901234567890123456789" |
| 95 |
|
| 96 |
# Now we need the version of the above string that expect will look |
| 97 |
# for. So, we need to convert all '\n' to '\r\n' and add a trailing |
| 98 |
# '\r\n'. |
| 99 |
regsub -all {\n} $test_string "\r\n" test_string2 |
| 100 |
set test_string2 "$test_string2\r\n" |
| 101 |
|
| 102 |
proc proc_write_test {} { |
| 103 |
global test test_string |
| 104 |
set path "/proc/systemtap/$test/command" |
| 105 |
|
| 106 |
proc_write_value $test $path $test_string |
| 107 |
return 0; |
| 108 |
} |
| 109 |
|
| 110 |
set systemtap_write_script { |
| 111 |
global iteration = 0 |
| 112 |
global saved_value[20] |
| 113 |
|
| 114 |
probe procfs("command").write { |
| 115 |
saved_value[iteration] = $value |
| 116 |
iteration++ |
| 117 |
} |
| 118 |
|
| 119 |
probe begin { |
| 120 |
printf("systemtap starting probe\n") |
| 121 |
} |
| 122 |
|
| 123 |
probe end { |
| 124 |
printf("systemtap ending probe\n") |
| 125 |
for (i = 0; i < iteration; i++) { |
| 126 |
printf("%s", saved_value[i]) |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
# We're forcing the MAXSTRINGLEN to be 512 chars to make sure we know |
| 132 |
# what we're testing. |
| 133 |
stap_run $test proc_write_test $test_string2 -DMAXSTRINGLEN=512 \ |
| 134 |
-e $systemtap_write_script -m $test |
| 135 |
exec /bin/rm -f ${test}.ko |