|
34 | 34 | from common import env_modify, no_mac, no_windows, only_windows, requires_native_clang, with_env_modify |
35 | 35 | from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file |
36 | 36 | from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary |
37 | | -from common import requires_wasm_eh, crossplatform, with_both_eh_sjlj, with_both_sjlj, also_with_standalone_wasm |
| 37 | +from common import requires_wasm_eh, crossplatform, with_both_eh_sjlj, with_both_sjlj |
| 38 | +from common import also_with_standalone_wasm, also_with_env_modify |
38 | 39 | from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, flaky |
39 | 40 | from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER |
40 | 41 | from common import requires_network |
@@ -5717,73 +5718,10 @@ def test_only_force_stdlibs_2(self): |
5717 | 5718 | self.run_process([EMXX, 'src.cpp', '-sDISABLE_EXCEPTION_CATCHING=0']) |
5718 | 5719 | self.assertContained('Caught exception: std::exception', self.run_js('a.out.js')) |
5719 | 5720 |
|
| 5721 | + @crossplatform |
| 5722 | + @also_with_env_modify({'gb_locale': {'LC_ALL': 'en_GB'}, 'long_tz': {'TZ': 'Asia/Kathmandu'}}) |
5720 | 5723 | def test_strftime_zZ(self): |
5721 | | - create_file('src.c', r''' |
5722 | | -#include <errno.h> |
5723 | | -#include <stdio.h> |
5724 | | -#include <string.h> |
5725 | | -#include <time.h> |
5726 | | - |
5727 | | -int main() { |
5728 | | - // Buffer to hold the current hour of the day. Format is HH + nul |
5729 | | - // character. |
5730 | | - char hour[3]; |
5731 | | - |
5732 | | - // Buffer to hold our ISO 8601 formatted UTC offset for the current |
5733 | | - // timezone. Format is [+-]hhmm + nul character. |
5734 | | - char utcOffset[6]; |
5735 | | - |
5736 | | - // Buffer to hold the timezone name or abbreviation. Just make it |
5737 | | - // sufficiently large to hold most timezone names. |
5738 | | - char timezone[128]; |
5739 | | - |
5740 | | - struct tm tm; |
5741 | | - |
5742 | | - // Get the current timestamp. |
5743 | | - const time_t now = time(NULL); |
5744 | | - |
5745 | | - // What time is that here? |
5746 | | - if (localtime_r(&now, &tm) == NULL) { |
5747 | | - const int error = errno; |
5748 | | - printf("Failed to get localtime for timestamp=%lld; errno=%d; %s", now, errno, strerror(error)); |
5749 | | - return 1; |
5750 | | - } |
5751 | | - |
5752 | | - size_t result = 0; |
5753 | | - |
5754 | | - // Get the formatted hour of the day. |
5755 | | - if ((result = strftime(hour, 3, "%H", &tm)) != 2) { |
5756 | | - const int error = errno; |
5757 | | - printf("Failed to format hour for timestamp=%lld; result=%zu; errno=%d; %s\n", |
5758 | | - now, result, error, strerror(error)); |
5759 | | - return 1; |
5760 | | - } |
5761 | | - printf("The current hour of the day is: %s\n", hour); |
5762 | | - |
5763 | | - // Get the formatted UTC offset in ISO 8601 format. |
5764 | | - if ((result = strftime(utcOffset, 6, "%z", &tm)) != 5) { |
5765 | | - const int error = errno; |
5766 | | - printf("Failed to format UTC offset for timestamp=%lld; result=%zu; errno=%d; %s\n", |
5767 | | - now, result, error, strerror(error)); |
5768 | | - return 1; |
5769 | | - } |
5770 | | - printf("The current timezone offset is: %s\n", utcOffset); |
5771 | | - |
5772 | | - // Get the formatted timezone name or abbreviation. We don't know how long |
5773 | | - // this will be, so just expect some data to be written to the buffer. |
5774 | | - if ((result = strftime(timezone, 128, "%Z", &tm)) == 0) { |
5775 | | - const int error = errno; |
5776 | | - printf("Failed to format timezone for timestamp=%lld; result=%zu; errno=%d; %s\n", |
5777 | | - now, result, error, strerror(error)); |
5778 | | - return 1; |
5779 | | - } |
5780 | | - printf("The current timezone is: %s\n", timezone); |
5781 | | - |
5782 | | - printf("ok!\n"); |
5783 | | - return 0; |
5784 | | -} |
5785 | | -''') |
5786 | | - self.do_runf('src.c', 'ok!') |
| 5724 | + self.do_runf('other/test_strftime_zZ.c', 'ok!') |
5787 | 5725 |
|
5788 | 5726 | def test_strptime_symmetry(self): |
5789 | 5727 | self.do_runf('strptime_symmetry.cpp', 'TEST PASSED') |
|
0 commit comments