Skip to content

Commit f4b3234

Browse files
authored
Fix test_unistd_isatty to open /dev/stdout in write only mode. NFC (#26544)
1 parent e8eaa01 commit f4b3234

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

test/test_other.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13165,13 +13165,17 @@ def test_unistd_swab(self):
1316513165
self.do_run_in_out_file_test('unistd/swab.c')
1316613166

1316713167
@also_with_noderawfs
13168+
@crossplatform
13169+
@no_deno('https://github.com/denoland/deno/issues/32995')
1316813170
def test_unistd_isatty(self):
1316913171
if '-DNODERAWFS' in self.cflags:
1317013172
# Under NODERAWFS istty reports accurate information about the file descriptors
1317113173
# of the node process. When we run tests we always capture stdout so we never expect
1317213174
# stdout to be a tty.
1317313175
stdin_isatty = os.isatty(0)
1317413176
self.cflags += ['-DEXPECT_STDOUT=0', f'-DEXPECT_STDIN={int(stdin_isatty)}']
13177+
if WINDOWS:
13178+
self.skipTest('depends on /dev filesystem')
1317513179
self.do_runf('unistd/isatty.c', 'success')
1317613180

1317713181
def test_unistd_login(self):
@@ -13184,7 +13188,7 @@ def test_unistd_sleep(self):
1318413188
@with_all_fs
1318513189
def test_unistd_fstatfs(self):
1318613190
if '-DNODERAWFS' in self.cflags and WINDOWS:
13187-
self.skipTest('Cannot look up /dev/stdout on windows')
13191+
self.skipTest('depends on /dev filesystem')
1318813192
self.do_run_in_out_file_test('unistd/fstatfs.c', cflags=['-sASSERTIONS=2'])
1318913193

1319013194
@no_windows("test is Linux-specific")

test/unistd/isatty.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ int main() {
2525
printf("EXPECT_STDIN: %d\n", EXPECT_STDIN);
2626
printf("EXPECT_STDOUT: %d\n", EXPECT_STDOUT);
2727

28+
printf("stdin -> %d\n", isatty(0));
29+
printf("stdout -> %d\n", isatty(1));
2830
assert(isatty(0) == EXPECT_STDIN);
2931
assert(isatty(1) == EXPECT_STDOUT);
3032

@@ -35,18 +37,22 @@ int main() {
3537

3638
fd = open("/dev/stdin", O_RDONLY);
3739
assert(fd >= 0);
40+
printf("/dev/stdin -> %d\n", isatty(fd));
3841
assert(isatty(fd) == EXPECT_STDIN);
3942

40-
fd = open("/dev/stdout", O_RDONLY);
43+
fd = open("/dev/stdout", O_WRONLY);
4144
assert(fd >= 0);
45+
printf("/dev/stdout -> %d\n", isatty(fd));
4246
assert(isatty(fd) == EXPECT_STDOUT);
4347

4448
fd = open("/dev/null", O_RDONLY);
4549
assert(fd >= 0);
50+
printf("/dev/null -> %d\n", isatty(fd));
4651
assert(isatty(fd) == 0);
4752

4853
fd = open("/dev", O_RDONLY);
4954
assert(fd >= 0);
55+
printf("/dev -> %d\n", isatty(fd));
5056
assert(isatty(fd) == 0);
5157

5258
puts("success");

0 commit comments

Comments
 (0)