t_fopen.c (302408) | t_fopen.c (350328) |
---|---|
1/* $NetBSD: t_fopen.c,v 1.3 2011/09/14 14:34:37 martin Exp $ */ 2 3/*- 4 * Copyright (c) 2011 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jukka Ruohonen. --- 44 unchanged lines hidden (view full) --- 53 FILE *f; 54 int fd; 55 56 /* 57 * Check that the file descriptor 58 * used to fdopen(3) a stream is 59 * closed once the stream is closed. 60 */ | 1/* $NetBSD: t_fopen.c,v 1.3 2011/09/14 14:34:37 martin Exp $ */ 2 3/*- 4 * Copyright (c) 2011 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jukka Ruohonen. --- 44 unchanged lines hidden (view full) --- 53 FILE *f; 54 int fd; 55 56 /* 57 * Check that the file descriptor 58 * used to fdopen(3) a stream is 59 * closed once the stream is closed. 60 */ |
61 fd = open(path, O_RDWR | O_CREAT); | 61 fd = open(path, O_RDWR | O_CREAT, 0600); |
62 63 ATF_REQUIRE(fd >= 0); 64 65 f = fdopen(fd, "w+"); 66 67 ATF_REQUIRE(f != NULL); 68 ATF_REQUIRE(fclose(f) == 0); 69 ATF_REQUIRE(close(fd) == -1); --- 10 unchanged lines hidden (view full) --- 80{ 81 atf_tc_set_md_var(tc, "descr", "Test errors from fdopen(3)"); 82} 83 84ATF_TC_BODY(fdopen_err, tc) 85{ 86 int fd; 87 | 62 63 ATF_REQUIRE(fd >= 0); 64 65 f = fdopen(fd, "w+"); 66 67 ATF_REQUIRE(f != NULL); 68 ATF_REQUIRE(fclose(f) == 0); 69 ATF_REQUIRE(close(fd) == -1); --- 10 unchanged lines hidden (view full) --- 80{ 81 atf_tc_set_md_var(tc, "descr", "Test errors from fdopen(3)"); 82} 83 84ATF_TC_BODY(fdopen_err, tc) 85{ 86 int fd; 87 |
88 fd = open(path, O_RDONLY | O_CREAT); | 88 fd = open(path, O_RDONLY | O_CREAT, 0600); |
89 ATF_REQUIRE(fd >= 0); 90 91 errno = 0; 92 ATF_REQUIRE_ERRNO(EINVAL, fdopen(fd, "w") == NULL); 93 94 errno = 0; 95 ATF_REQUIRE_ERRNO(EINVAL, fdopen(fd, "a") == NULL); 96 --- 24 unchanged lines hidden (view full) --- 121 FILE *f; 122 int fd; 123 124 /* 125 * Verify that the file position associated 126 * with the stream corresponds with the offset 127 * set earlier for the file descriptor. 128 */ | 89 ATF_REQUIRE(fd >= 0); 90 91 errno = 0; 92 ATF_REQUIRE_ERRNO(EINVAL, fdopen(fd, "w") == NULL); 93 94 errno = 0; 95 ATF_REQUIRE_ERRNO(EINVAL, fdopen(fd, "a") == NULL); 96 --- 24 unchanged lines hidden (view full) --- 121 FILE *f; 122 int fd; 123 124 /* 125 * Verify that the file position associated 126 * with the stream corresponds with the offset 127 * set earlier for the file descriptor. 128 */ |
129 fd = open(path, O_RDWR | O_CREAT); | 129 fd = open(path, O_RDWR | O_CREAT, 0600); |
130 131 ATF_REQUIRE(fd >= 0); 132 ATF_REQUIRE(write(fd, "garbage", 7) == 7); 133 ATF_REQUIRE(lseek(fd, 3, SEEK_SET) == 3); 134 135 f = fdopen(fd, "r+"); 136 137 ATF_REQUIRE(f != NULL); --- 309 unchanged lines hidden --- | 130 131 ATF_REQUIRE(fd >= 0); 132 ATF_REQUIRE(write(fd, "garbage", 7) == 7); 133 ATF_REQUIRE(lseek(fd, 3, SEEK_SET) == 3); 134 135 f = fdopen(fd, "r+"); 136 137 ATF_REQUIRE(f != NULL); --- 309 unchanged lines hidden --- |