tests: lib: c_lib: add test suite for remove api
Add test suite for remove of zephyr native libc Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com> Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
This commit is contained in:
parent
abf62699cb
commit
c044f0c89d
5 changed files with 97 additions and 0 deletions
8
tests/lib/c_lib/stdio/CMakeLists.txt
Normal file
8
tests/lib/c_lib/stdio/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(stdio)
|
||||
|
||||
FILE(GLOB app_sources src/*.c)
|
||||
target_sources(app PRIVATE ${app_sources})
|
14
tests/lib/c_lib/stdio/app.overlay
Normal file
14
tests/lib/c_lib/stdio/app.overlay
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Linumiz
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
ramdisk0 {
|
||||
compatible = "zephyr,ram-disk";
|
||||
disk-name = "RAM";
|
||||
sector-size = <512>;
|
||||
sector-count = <160>;
|
||||
};
|
||||
};
|
6
tests/lib/c_lib/stdio/prj.conf
Normal file
6
tests/lib/c_lib/stdio/prj.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_TEST_USERSPACE=y
|
||||
CONFIG_ZTEST_FATAL_HOOK=y
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_FILE_SYSTEM=y
|
||||
CONFIG_FAT_FILESYSTEM_ELM=y
|
48
tests/lib/c_lib/stdio/src/main.c
Normal file
48
tests/lib/c_lib/stdio/src/main.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Linumiz
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/ztest.h>
|
||||
#include <zephyr/ztest_error_hook.h>
|
||||
#include <ff.h>
|
||||
#include <zephyr/fs/fs.h>
|
||||
|
||||
#define FATFS_MNTP "/RAM:"
|
||||
#define TEST_FILE FATFS_MNTP"/testfile.txt"
|
||||
|
||||
static FATFS fat_fs;
|
||||
|
||||
static struct fs_mount_t fatfs_mnt = {
|
||||
.type = FS_FATFS,
|
||||
.mnt_point = FATFS_MNTP,
|
||||
.fs_data = &fat_fs,
|
||||
};
|
||||
|
||||
ZTEST_SUITE(libc_stdio, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/**
|
||||
* @brief Test for remove API
|
||||
*
|
||||
* @details Test deletes a file through remove API.
|
||||
*/
|
||||
ZTEST(libc_stdio, test_remove)
|
||||
{
|
||||
struct fs_file_t file;
|
||||
|
||||
fs_file_t_init(&file);
|
||||
|
||||
zassert_ok(fs_mount(&fatfs_mnt), "Error in mount file system\n");
|
||||
zassert_equal(fs_open(&file, TEST_FILE, FS_O_CREATE), 0,
|
||||
"Error creating file\n");
|
||||
zassert_ok(fs_close(&file), "Error closing file\n");
|
||||
zassert_ok(remove(TEST_FILE), "Error removing file: %d\n", errno);
|
||||
zassert_equal(remove(""), -1, "Error Invalid path removed\n");
|
||||
zassert_equal(remove(NULL), -1, "Error Invalid path removed\n");
|
||||
zassert_ok(fs_unmount(&fatfs_mnt), "Error while unmount file system\n");
|
||||
}
|
21
tests/lib/c_lib/stdio/testcase.yaml
Normal file
21
tests/lib/c_lib/stdio/testcase.yaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
common:
|
||||
tags:
|
||||
- clib
|
||||
min_ram: 128
|
||||
filter: not CONFIG_NATIVE_LIBC
|
||||
tests:
|
||||
libraries.libc.common.stdio.minimal:
|
||||
tags: minimal_libc
|
||||
filter: CONFIG_MINIMAL_LIBC_SUPPORTED
|
||||
extra_configs:
|
||||
- CONFIG_MINIMAL_LIBC=y
|
||||
libraries.libc.common.stdio.picolibc:
|
||||
tags: picolibc
|
||||
filter: CONFIG_PICOLIBC_SUPPORTED
|
||||
extra_configs:
|
||||
- CONFIG_PICOLIBC=y
|
||||
libraries.libc.common.stdio.newlib:
|
||||
tags: newlib
|
||||
filter: TOOLCHAIN_HAS_NEWLIB == 1
|
||||
extra_configs:
|
||||
- CONFIG_NEWLIB_LIBC=y
|
Loading…
Add table
Add a link
Reference in a new issue