Loading...
--- Libc/Libc-1725.40.4/tests/stdtime.c
+++ Libc/Libc-1158.1.2/tests/stdtime.c
@@ -4,7 +4,6 @@
#include <string.h>
#include <locale.h>
#include <err.h>
-#include <TargetConditionals.h>
#include <darwintest.h>
@@ -19,25 +18,24 @@
T_EXPECT_EQ(percent_j_out, standard_out, NULL);
}
-#if !TARGET_OS_BRIDGE
T_DECL(strptime_PR_5879606, "alloca(strlen(input)) in strptime(\"%Z\")")
{
struct tm tm;
time_t t = time(NULL);
size_t s = 100000000;
char *buf;
- char tz[100] = { 0 };
localtime_r(&t, &tm);
T_LOG("%s", asctime(&tm));
T_ASSERT_NOTNULL(strptime("GMT", "%Z", &tm), "strptime GMT");
T_LOG("%s", asctime(&tm));
- strftime(tz, sizeof(tz), "%Z", &tm);
- T_LOG("The current time zone name is: %s\n", tz);
+ localtime_r(&t, &tm);
+ T_ASSERT_NOTNULL(strptime("PST", "%Z", &tm), "strptime PST");
+ T_LOG("%s", asctime(&tm));
localtime_r(&t, &tm);
- T_ASSERT_NOTNULL(strptime(tz, "%Z", &tm), "strptime local TZ name");
+ T_ASSERT_NOTNULL(strptime("PDT", "%Z", &tm), "strptime PDT");
T_LOG("%s", asctime(&tm));
T_QUIET; T_ASSERT_NOTNULL((buf = malloc(s)), NULL);
@@ -49,18 +47,10 @@
T_DECL(strptime_PR_6882179, "date command fails with 'illegal time format'")
{
- struct tm tm, tmptm;
- time_t t = time(NULL);
- char *buf = NULL;
- char tz[100] = { 0 };
+ struct tm tm;
+ char buf[] = "Tue May 12 18:19:41 PDT 2009";
- localtime_r(&t, &tmptm);
- strftime(tz, sizeof(tz), "%Z", &tmptm);
- T_LOG("The current time zone name is: %s\n", tz);
-
- asprintf(&buf, "Tue May 12 18:19:41 %s 2009", tz);
T_ASSERT_NOTNULL(strptime(buf, "%a %b %d %T %Z %Y", &tm), NULL);
- free(buf);
T_EXPECT_EQ(tm.tm_sec, 0x29, NULL);
T_EXPECT_EQ(tm.tm_min, 0x13, NULL);
@@ -71,7 +61,6 @@
T_EXPECT_EQ(tm.tm_wday, 0x2, NULL);
T_EXPECT_EQ(tm.tm_yday, 0x83, NULL);
}
-#endif
T_DECL(strptime_lukemftp, "year parsing"){
struct tm tm;
@@ -81,12 +70,10 @@
T_DECL(strptime_five_digit_year, "strptime(%Y) with a 5 digit year")
{
- // POSIX conformance requires that %Y only use 4 characters, so use the
- // field width to change that for this test.
char *timestr = "20080922T020000";
struct tm tm;
bzero(&tm, sizeof(tm));
- T_ASSERT_NOTNULL(strptime("10001", "%5Y", &tm), NULL);
+ T_ASSERT_NOTNULL(strptime("10001", "%Y", &tm), NULL);
T_EXPECT_EQ(tm.tm_year, 10001 - 1900, NULL);
T_ASSERT_NOTNULL(strptime(timestr, "%Y%m%dT%H%M%S", &tm), NULL);
}
@@ -153,20 +140,8 @@
}
}
-#if !TARGET_OS_BRIDGE
-T_DECL(strptime_asctime, "strptime->asctime",
- T_META_REQUIRES_OS_VARIANT_NOT("IsDarwinOS")) {
-
- struct tm tmptm;
- time_t t = time(NULL);
- char tz[100] = { 0 };
- localtime_r(&t, &tmptm);
- strftime(tz, sizeof(tz), "%Z %z", &tmptm);
- T_LOG("The current time zone offset is: %s\n", tz);
- if (strcmp(tz, "PST -0800") != 0 && strcmp(tz, "PDT -0700") != 0) {
- T_SKIP("This test expects the device to be in Pacific time");
- }
-
+T_DECL(strptime_asctime, "strptime->asctime")
+{
char *test[] = {
"Sun, 6 Apr 2003 03:30:00 -0500",
"Sun, 6 Apr 2003 04:30:00 -0500",
@@ -201,4 +176,3 @@
i++;
}
}
-#endif