| 1 |
# Note this test is written in a bit of an odd way. In systemtap 2.2 |
| 2 |
# and above, ctime will raise an error. For systemtap versions before |
| 3 |
# 2.2, ctime returned one of three error strings. Map those error |
| 4 |
# strings to one error. |
| 5 |
|
| 6 |
probe begin |
| 7 |
{ |
| 8 |
// epoch |
| 9 |
println(ctime(0)) |
| 10 |
|
| 11 |
// epoch - 1 |
| 12 |
println(ctime(-1)) |
| 13 |
|
| 14 |
// epoch + 1 |
| 15 |
println(ctime(1)) |
| 16 |
|
| 17 |
// Some funny numbers |
| 18 |
println(ctime(100000000)) |
| 19 |
println(ctime(1234567890)) |
| 20 |
println(ctime(1073741824)) |
| 21 |
println(ctime(0x50000000)) |
| 22 |
|
| 23 |
// some time really long ago |
| 24 |
secspermin = 60 |
| 25 |
minsperhour = 60 |
| 26 |
hoursperday = 24 |
| 27 |
secsperhour = secspermin * minsperhour |
| 28 |
secsperday = secsperhour * hoursperday |
| 29 |
epoch_year = 1970 |
| 30 |
time = -1 * (epoch_year - 1000) * 365 * secsperday |
| 31 |
try { |
| 32 |
result = ctime(time) |
| 33 |
if (result == "far far in the future..." |
| 34 |
|| result == "a long, long time ago..." |
| 35 |
|| result == "<invalid time>") |
| 36 |
println("conversion error") |
| 37 |
else |
| 38 |
println(result) |
| 39 |
} catch { |
| 40 |
println("conversion error") |
| 41 |
} |
| 42 |
// some time in the far future |
| 43 |
time = (9999 - epoch_year) * 365 * secsperday |
| 44 |
try { |
| 45 |
result = ctime(time) |
| 46 |
if (result == "far far in the future..." |
| 47 |
|| result == "a long, long time ago..." |
| 48 |
|| result == "<invalid time>") |
| 49 |
println("conversion error") |
| 50 |
else |
| 51 |
println(result) |
| 52 |
} catch { |
| 53 |
println("conversion error") |
| 54 |
} |
| 55 |
|
| 56 |
// min 32 bit |
| 57 |
time = -2147483648 |
| 58 |
println(ctime(time)) |
| 59 |
|
| 60 |
// over the edge, a long, long time ago... |
| 61 |
time-- |
| 62 |
try { |
| 63 |
result = ctime(time) |
| 64 |
if (result == "far far in the future..." |
| 65 |
|| result == "a long, long time ago..." |
| 66 |
|| result == "<invalid time>") |
| 67 |
println("conversion error") |
| 68 |
else |
| 69 |
println(result) |
| 70 |
} catch { |
| 71 |
println("conversion error") |
| 72 |
} |
| 73 |
|
| 74 |
// max 32 bit |
| 75 |
time = 2147483647 |
| 76 |
println(ctime(time)) |
| 77 |
|
| 78 |
// over the edge, far far in the future... |
| 79 |
time++ |
| 80 |
try { |
| 81 |
result = ctime(time) |
| 82 |
if (result == "far far in the future..." |
| 83 |
|| result == "a long, long time ago..." |
| 84 |
|| result == "<invalid time>") |
| 85 |
println("conversion error") |
| 86 |
else |
| 87 |
println(result) |
| 88 |
} catch { |
| 89 |
println("conversion error") |
| 90 |
} |
| 91 |
|
| 92 |
// min 64 bit |
| 93 |
try { |
| 94 |
result = ctime(-9223372036854775808) |
| 95 |
if (result == "far far in the future..." |
| 96 |
|| result == "a long, long time ago..." |
| 97 |
|| result == "<invalid time>") |
| 98 |
println("conversion error") |
| 99 |
else |
| 100 |
println(result) |
| 101 |
} catch { |
| 102 |
println("conversion error") |
| 103 |
} |
| 104 |
|
| 105 |
// max 64 bit |
| 106 |
try { |
| 107 |
result = ctime(9223372036854775807) |
| 108 |
if (result == "far far in the future..." |
| 109 |
|| result == "a long, long time ago..." |
| 110 |
|| result == "<invalid time>") |
| 111 |
println("conversion error") |
| 112 |
else |
| 113 |
println(result) |
| 114 |
} catch { |
| 115 |
println("conversion error") |
| 116 |
} |
| 117 |
|
| 118 |
exit() |
| 119 |
} |