1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <stdio.h>
17 #include <string.h>
18 #include <unistd.h>
19 #include <fcntl.h>
20 #include "test.h"
21
22 /**
23 * @tc.name : unlink_0100
24 * @tc.desc : Test the timegm result when tm exceeds the limit
25 * @tc.level : Level 0
26 */
unlink_0100(void)27 void unlink_0100(void)
28 {
29 int fd = open("/data/tests/libc-test/src/test_unlink.txt", O_CREAT);
30 int error_code = -1;
31 if (fd == error_code) {
32 t_error("%s unlink create file error", __func__);
33 return;
34 }
35 close(fd);
36 int result = unlink("/data/tests/libc-test/src/test_unlink.txt");
37 if (result != 0) {
38 t_error("%s unlink get result is %d not want 0", __func__, result);
39 }
40 }
41
42 /**
43 * @tc.name : unlink_0200
44 * @tc.desc : Test the timegm result when tm exceeds the limit
45 * @tc.level : Level 1
46 */
unlink_0200(void)47 void unlink_0200(void)
48 {
49 int result = unlink("/data/tests/libc-test/src/unexist_test_unlink.txt");
50 int error_code = -1;
51 if (result != error_code) {
52 t_error("%s unlink get result is %d not want -1", __func__, result);
53 }
54 }
55
main(int argc,char * argv[])56 int main(int argc, char *argv[])
57 {
58 unlink_0100();
59 unlink_0200();
60 return t_status;
61 }