1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2025 Oxide Computer Company
14 */
15
16 /*
17 * This file tests that the parsed tzname is equal to what was passed in as
18 * args. We use the arguments as TZ=arg0, name0=arg1, name1=arg2.
19 */
20
21 #include <time.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <err.h>
26
27 int
main(int argc,char * argv[])28 main(int argc, char *argv[])
29 {
30 int ret = EXIT_SUCCESS;
31
32 if (argc != 4) {
33 (void) fprintf(stderr, "Usage: tznames <TZ> <tzname0> "
34 "<tzname1>\n");
35 exit(EXIT_FAILURE);
36 }
37
38 if (setenv("TZ", argv[1], 1) != 0) {
39 err(EXIT_FAILURE, "failed to set TZ to %s", argv[1]);
40 }
41
42 tzset();
43
44 if (strcmp(tzname[0], argv[2]) != 0) {
45 warnx("TEST FAILED: TZ %s: found tzname[0] %s, expected %s",
46 argv[1], tzname[0], argv[2]);
47 ret = EXIT_FAILURE;
48 }
49
50 if (strcmp(tzname[1], argv[3]) != 0) {
51 warnx("TEST FAILED: TZ %s: found tzname[1] %s, expected %s",
52 argv[1], tzname[1], argv[3]);
53 ret = EXIT_FAILURE;
54 }
55
56 return (ret);
57 }
58