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 "test.h" 19 20/** 21 * @tc.name : tmpnam_0100 22 * @tc.desc : When buffer is provided, the pointer points to the custom buffer 23 * @tc.level : Level 0 24 */ 25void tmpnam_0100(void) 26{ 27 char buffer[L_tmpnam]; 28 char *p = tmpnam(buffer); 29 if (p == NULL) { 30 t_error("%s tmpnam failed", __func__); 31 } 32 if (strlen(buffer) == 0) { 33 t_error("%s creat temporary name failed", __func__); 34 } 35} 36 37/** 38 * @tc.name : tmpnam_0200 39 * @tc.desc : When str is a null pointer, returns a pointer to the internal buffer 40 * @tc.level : Level 1 41 */ 42void tmpnam_0200(void) 43{ 44 char *p = tmpnam(NULL); 45 if (p == NULL) { 46 t_error("%s tmpnam failed", __func__); 47 } 48 if (strlen(p) == 0) { 49 t_error("%s creat temporary name failed", __func__); 50 } 51} 52 53int main(int argc, char *argv[]) 54{ 55 // tmpnam_0100(); 56 // tmpnam_0200(); 57 return t_status; 58} 59