# Note this test is written in a bit of an odd way. In systemtap 2.2 # and above, ctime will raise an error. For systemtap versions before # 2.2, ctime returned one of three error strings. Map those error # strings to one error. probe begin { // epoch println(ctime(0)) // epoch - 1 println(ctime(-1)) // epoch + 1 println(ctime(1)) // Some funny numbers println(ctime(100000000)) println(ctime(1234567890)) println(ctime(1073741824)) println(ctime(0x50000000)) // some time really long ago secspermin = 60 minsperhour = 60 hoursperday = 24 secsperhour = secspermin * minsperhour secsperday = secsperhour * hoursperday epoch_year = 1970 time = -1 * (epoch_year - 1000) * 365 * secsperday try { result = ctime(time) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } // some time in the far future time = (9999 - epoch_year) * 365 * secsperday try { result = ctime(time) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } // min 32 bit time = -2147483648 println(ctime(time)) // over the edge, a long, long time ago... time-- try { result = ctime(time) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } // max 32 bit time = 2147483647 println(ctime(time)) // over the edge, far far in the future... time++ try { result = ctime(time) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } // min 64 bit try { result = ctime(-9223372036854775808) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } // max 64 bit try { result = ctime(9223372036854775807) if (result == "far far in the future..." || result == "a long, long time ago..." || result == "") println("conversion error") else println(result) } catch { println("conversion error") } exit() }