Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -13165,13 +13165,17 @@ def test_unistd_swab(self):
self.do_run_in_out_file_test('unistd/swab.c')

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

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

@no_windows("test is Linux-specific")
Expand Down
8 changes: 7 additions & 1 deletion test/unistd/isatty.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ int main() {
printf("EXPECT_STDIN: %d\n", EXPECT_STDIN);
printf("EXPECT_STDOUT: %d\n", EXPECT_STDOUT);

printf("stdin -> %d\n", isatty(0));
printf("stdout -> %d\n", isatty(1));
assert(isatty(0) == EXPECT_STDIN);
assert(isatty(1) == EXPECT_STDOUT);

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

fd = open("/dev/stdin", O_RDONLY);
assert(fd >= 0);
printf("/dev/stdin -> %d\n", isatty(fd));
assert(isatty(fd) == EXPECT_STDIN);

fd = open("/dev/stdout", O_RDONLY);
fd = open("/dev/stdout", O_WRONLY);
assert(fd >= 0);
printf("/dev/stdout -> %d\n", isatty(fd));
assert(isatty(fd) == EXPECT_STDOUT);

fd = open("/dev/null", O_RDONLY);
assert(fd >= 0);
printf("/dev/null -> %d\n", isatty(fd));
assert(isatty(fd) == 0);

fd = open("/dev", O_RDONLY);
assert(fd >= 0);
printf("/dev -> %d\n", isatty(fd));
assert(isatty(fd) == 0);

puts("success");
Expand Down
Loading