Skip to content

Commit e9a03c0

Browse files
committed
Address sbc100 review comments
1 parent f9b340a commit e9a03c0

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

test/other/tty.c renamed to test/other/libtty.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <assert.h>
12
#include <emscripten.h>
23
#include <errno.h>
34
#include <fcntl.h>
@@ -113,7 +114,7 @@ int main() {
113114

114115
printf("\nTest 1: open custom TTY device and check isatty\n");
115116
int fd = open("/custom_tty", O_RDWR);
116-
printf("open custom_tty: %d\n", fd >= 0 ? 1 : 0);
117+
assert(fd >= 0);
117118
printf("isatty: %d\n", isatty(fd));
118119
printf("errno after open: %s\n", strerror(errno));
119120
errno = 0;
@@ -160,7 +161,7 @@ int main() {
160161

161162
printf("\nTest 8: no put_char\n");
162163
fd = open("/tty_no_putchar", O_WRONLY);
163-
printf("open: %d\n", fd >= 0 ? 1 : 0);
164+
assert(fd >= 0);
164165
bytesWritten = write(fd, writeBuffer, strlen(writeBuffer));
165166
printf("write: %zd\n", bytesWritten);
166167
printf("errno: %s\n", strerror(errno));
@@ -169,7 +170,7 @@ int main() {
169170

170171
printf("\nTest 9: no get_char\n");
171172
fd = open("/tty_no_getchar", O_RDONLY);
172-
printf("open: %d\n", fd >= 0 ? 1 : 0);
173+
assert(fd >= 0);
173174
bytesRead = read(fd, readBuffer, sizeof(readBuffer));
174175
printf("read: %zd\n", bytesRead);
175176
printf("errno: %s\n", strerror(errno));
@@ -178,7 +179,7 @@ int main() {
178179

179180
printf("\nTest 10: put_char throws\n");
180181
fd = open("/tty_throw_putchar", O_WRONLY);
181-
printf("open: %d\n", fd >= 0 ? 1 : 0);
182+
assert(fd >= 0);
182183
bytesWritten = write(fd, writeBuffer, strlen(writeBuffer));
183184
printf("write: %zd\n", bytesWritten);
184185
printf("errno: %s\n", strerror(errno));
@@ -187,7 +188,7 @@ int main() {
187188

188189
printf("\nTest 11: get_char throws\n");
189190
fd = open("/tty_throw_getchar", O_RDONLY);
190-
printf("open: %d\n", fd >= 0 ? 1 : 0);
191+
assert(fd >= 0);
191192
bytesRead = read(fd, readBuffer, sizeof(readBuffer));
192193
printf("read: %zd\n", bytesRead);
193194
printf("errno: %s\n", strerror(errno));
@@ -196,7 +197,7 @@ int main() {
196197

197198
printf("\nTest 12: get_char returns undefined\n");
198199
fd = open("/tty_empty", O_RDONLY);
199-
printf("open: %d\n", fd >= 0 ? 1 : 0);
200+
assert(fd >= 0);
200201
bytesRead = read(fd, readBuffer, sizeof(readBuffer));
201202
printf("read: %zd\n", bytesRead);
202203
printf("errno: %s\n", strerror(errno));
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
Test 1: open custom TTY device and check isatty
3-
open custom_tty: 1
43
isatty: 1
54
errno after open: Success
65

@@ -33,27 +32,22 @@ errno after fsync: Success
3332
fsync called
3433

3534
Test 8: no put_char
36-
open: 1
3735
write: -1
3836
errno: No such device or address
3937

4038
Test 9: no get_char
41-
open: 1
4239
read: -1
4340
errno: No such device or address
4441

4542
Test 10: put_char throws
46-
open: 1
4743
write: -1
4844
errno: I/O error
4945

5046
Test 11: get_char throws
51-
open: 1
5247
read: -1
5348
errno: I/O error
5449

5550
Test 12: get_char returns undefined
56-
open: 1
5751
read: -1
5852
errno: Resource temporarily unavailable
5953

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13176,7 +13176,7 @@ def test_unistd_isatty(self):
1317613176
self.do_runf('unistd/isatty.c', 'success')
1317713177

1317813178
def test_libtty(self):
13179-
self.do_other_test('tty.c')
13179+
self.do_other_test('libtty.c')
1318013180

1318113181
def test_unistd_login(self):
1318213182
self.do_run_in_out_file_test('unistd/login.c')

0 commit comments

Comments
 (0)