| 1 |
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
| 2 |
# See https://llvm.org/LICENSE.txt for license information. |
| 3 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 |
|
| 5 |
# Tests for LLVM libc unistd.h functions. |
| 6 |
|
| 7 |
load("//libc/test:libc_test_rules.bzl", "libc_test") |
| 8 |
|
| 9 |
package(default_visibility = ["//visibility:public"]) |
| 10 |
|
| 11 |
licenses(["notice"]) |
| 12 |
|
| 13 |
libc_test( |
| 14 |
name = "access_test", |
| 15 |
srcs = ["access_test.cpp"], |
| 16 |
deps = [ |
| 17 |
"//libc:access", |
| 18 |
"//libc:close", |
| 19 |
"//libc:open", |
| 20 |
"//libc:unlink", |
| 21 |
"//libc/test/UnitTest:errno_test_helpers", |
| 22 |
], |
| 23 |
) |
| 24 |
|
| 25 |
libc_test( |
| 26 |
name = "dup_test", |
| 27 |
srcs = ["dup_test.cpp"], |
| 28 |
deps = [ |
| 29 |
"//libc:close", |
| 30 |
"//libc:dup", |
| 31 |
"//libc:open", |
| 32 |
"//libc:read", |
| 33 |
"//libc:unlink", |
| 34 |
"//libc:write", |
| 35 |
"//libc/test/UnitTest:errno_test_helpers", |
| 36 |
], |
| 37 |
) |
| 38 |
|
| 39 |
libc_test( |
| 40 |
name = "dup2_test", |
| 41 |
srcs = ["dup2_test.cpp"], |
| 42 |
deps = [ |
| 43 |
"//libc:close", |
| 44 |
"//libc:dup2", |
| 45 |
"//libc:open", |
| 46 |
"//libc:read", |
| 47 |
"//libc:unlink", |
| 48 |
"//libc:write", |
| 49 |
"//libc/test/UnitTest:errno_test_helpers", |
| 50 |
], |
| 51 |
) |
| 52 |
|
| 53 |
libc_test( |
| 54 |
name = "dup3_test", |
| 55 |
srcs = ["dup3_test.cpp"], |
| 56 |
deps = [ |
| 57 |
"//libc:close", |
| 58 |
"//libc:dup3", |
| 59 |
"//libc:open", |
| 60 |
"//libc:read", |
| 61 |
"//libc:unlink", |
| 62 |
"//libc:write", |
| 63 |
"//libc/test/UnitTest:errno_test_helpers", |
| 64 |
], |
| 65 |
) |
| 66 |
|
| 67 |
libc_test( |
| 68 |
name = "ftruncate_test", |
| 69 |
srcs = ["ftruncate_test.cpp"], |
| 70 |
deps = [ |
| 71 |
"//libc:__support_cpp_string_view", |
| 72 |
"//libc:close", |
| 73 |
"//libc:ftruncate", |
| 74 |
"//libc:open", |
| 75 |
"//libc:read", |
| 76 |
"//libc:unlink", |
| 77 |
"//libc:write", |
| 78 |
"//libc/test/UnitTest:errno_test_helpers", |
| 79 |
], |
| 80 |
) |
| 81 |
|
| 82 |
libc_test( |
| 83 |
name = "pread_pwrite_test", |
| 84 |
srcs = ["pread_pwrite_test.cpp"], |
| 85 |
deps = [ |
| 86 |
"//libc:close", |
| 87 |
"//libc:fsync", |
| 88 |
"//libc:open", |
| 89 |
"//libc:pread", |
| 90 |
"//libc:pwrite", |
| 91 |
"//libc:unlink", |
| 92 |
"//libc:write", |
| 93 |
"//libc/test/UnitTest:errno_test_helpers", |
| 94 |
], |
| 95 |
) |
| 96 |
|
| 97 |
libc_test( |
| 98 |
name = "read_write_test", |
| 99 |
srcs = ["read_write_test.cpp"], |
| 100 |
deps = [ |
| 101 |
"//libc:close", |
| 102 |
"//libc:fsync", |
| 103 |
"//libc:open", |
| 104 |
"//libc:read", |
| 105 |
"//libc:remove", |
| 106 |
"//libc:write", |
| 107 |
"//libc/test/UnitTest:errno_test_helpers", |
| 108 |
], |
| 109 |
) |
| 110 |
|
| 111 |
libc_test( |
| 112 |
name = "link_test", |
| 113 |
srcs = ["link_test.cpp"], |
| 114 |
deps = [ |
| 115 |
"//libc:close", |
| 116 |
"//libc:link", |
| 117 |
"//libc:open", |
| 118 |
"//libc:unlink", |
| 119 |
"//libc/test/UnitTest:errno_test_helpers", |
| 120 |
], |
| 121 |
) |
| 122 |
|
| 123 |
libc_test( |
| 124 |
name = "swab_test", |
| 125 |
srcs = ["swab_test.cpp"], |
| 126 |
deps = [ |
| 127 |
"//libc:string_utils", |
| 128 |
"//libc:swab", |
| 129 |
], |
| 130 |
) |
| 131 |
|
| 132 |
libc_test( |
| 133 |
name = "symlink_test", |
| 134 |
srcs = ["symlink_test.cpp"], |
| 135 |
deps = [ |
| 136 |
"//libc:close", |
| 137 |
"//libc:open", |
| 138 |
"//libc:symlink", |
| 139 |
"//libc:unlink", |
| 140 |
"//libc/test/UnitTest:errno_test_helpers", |
| 141 |
], |
| 142 |
) |
| 143 |
|
| 144 |
libc_test( |
| 145 |
name = "truncate_test", |
| 146 |
srcs = ["truncate_test.cpp"], |
| 147 |
deps = [ |
| 148 |
"//libc:__support_cpp_string_view", |
| 149 |
"//libc:close", |
| 150 |
"//libc:open", |
| 151 |
"//libc:read", |
| 152 |
"//libc:truncate", |
| 153 |
"//libc:unlink", |
| 154 |
"//libc:write", |
| 155 |
"//libc/test/UnitTest:errno_test_helpers", |
| 156 |
], |
| 157 |
) |
| 158 |
|
| 159 |
libc_test( |
| 160 |
name = "unlink_test", |
| 161 |
srcs = ["unlink_test.cpp"], |
| 162 |
deps = [ |
| 163 |
"//libc:close", |
| 164 |
"//libc:open", |
| 165 |
"//libc:unlink", |
| 166 |
"//libc/test/UnitTest:errno_test_helpers", |
| 167 |
], |
| 168 |
) |
| 169 |
|
| 170 |
libc_test( |
| 171 |
name = "getppid_test", |
| 172 |
srcs = ["getppid_test.cpp"], |
| 173 |
deps = [ |
| 174 |
"//libc:getppid", |
| 175 |
], |
| 176 |
) |
| 177 |
|
| 178 |
libc_test( |
| 179 |
name = "getuid_test", |
| 180 |
srcs = ["getuid_test.cpp"], |
| 181 |
deps = [ |
| 182 |
"//libc:getuid", |
| 183 |
], |
| 184 |
) |
| 185 |
|
| 186 |
libc_test( |
| 187 |
name = "isatty_test", |
| 188 |
srcs = ["isatty_test.cpp"], |
| 189 |
deps = [ |
| 190 |
"//libc:close", |
| 191 |
"//libc:isatty", |
| 192 |
"//libc:open", |
| 193 |
"//libc/test/UnitTest:errno_test_helpers", |
| 194 |
], |
| 195 |
) |
| 196 |
|
| 197 |
libc_test( |
| 198 |
name = "geteuid_test", |
| 199 |
srcs = ["geteuid_test.cpp"], |
| 200 |
deps = [ |
| 201 |
"//libc:geteuid", |
| 202 |
], |
| 203 |
) |
| 204 |
|
| 205 |
# TODO: add rules for functions modifying directories. |
| 206 |
|
| 207 |
#TODO: Enable once fullbuild is added to bazel, since this depends on a macro |
| 208 |
# definition in the public header |
| 209 |
|
| 210 |
# libc_test( |
| 211 |
# name = "syscall_test", |
| 212 |
# srcs = ["syscall_test.cpp"], |
| 213 |
# deps = [ |
| 214 |
# "//libc:syscall", |
| 215 |
# ], |
| 216 |
# ) |
| 217 |
|
| 218 |
# TODO: add once sysconf is complete |
| 219 |
|
| 220 |
# libc_test( |
| 221 |
# name = "sysconf_test", |
| 222 |
# srcs = ["sysconf_test.cpp"], |
| 223 |
# deps = [ |
| 224 |
# "//libc:sysconf", |
| 225 |
# ], |
| 226 |
# ) |
| 227 |
|
| 228 |
# TODO: add fopencookie and fflush |
| 229 |
|
| 230 |
# libc_test( |
| 231 |
# name = "getopt_test", |
| 232 |
# srcs = ["getopt_test.cpp"], |
| 233 |
# deps = [ |
| 234 |
# "//libc:__support_cpp_array", |
| 235 |
# "//libc:getopt", |
| 236 |
# "//libc:fopencookie", |
| 237 |
# "//libc:fflush", |
| 238 |
# ], |
| 239 |
# ) |