The introduction of `sanitycheck --list-tests` fails to properly parse
the subcases in tests/subsys/fs/nffs_api/ beacause four of them are
all packed with #ifdefs in a single src/main.c.
So this breaks that testcase in four:
- creating a common folder with the code itself
- moving the common code in */src/main.c to common/test_nffs.h and
adding ../common/*.c to the sources
- thinning each testcase.yaml to have only the needed testcase
definition
- adding zephyr_include_directories(../common) to the cmakefiles
so we now produce with --list-tests
- filesystem.nffs.basic.append
- filesystem.nffs.basic.corrupt_block
- filesystem.nffs.basic.corrupt_scratch
- filesystem.nffs.basic.fs_mount
- filesystem.nffs.basic.gc
- filesystem.nffs.basic.gc_on_oom
- filesystem.nffs.basic.incomplete_block
- filesystem.nffs.basic.large_write
- filesystem.nffs.basic.long_filename
- filesystem.nffs.basic.lost_found
- filesystem.nffs.basic.many_children
- filesystem.nffs.basic.mkdir
- filesystem.nffs.basic.open
- filesystem.nffs.basic.overwrite_many
- filesystem.nffs.basic.overwrite_one
- filesystem.nffs.basic.overwrite_three
- filesystem.nffs.basic.overwrite_two
- filesystem.nffs.basic.read
- filesystem.nffs.basic.readdir
- filesystem.nffs.basic.rename
- filesystem.nffs.basic.split_file
- filesystem.nffs.basic.unlink
- filesystem.nffs.basic.wear_level
- filesystem.nffs.cache.cache_large_file
- filesystem.nffs.cache.fs_mount
- filesystem.nffs.large.fs_mount
- filesystem.nffs.large.large_system
- filesystem.nffs.large.large_unlink
- filesystem.nffs.performance.fs_mount
- filesystem.nffs.performance.performance
30 total.
vs before, that we did:
- filesystem.nffs.basic.append
- filesystem.nffs.basic.corrupt_block
- filesystem.nffs.basic.corrupt_scratch
- filesystem.nffs.basic.fs_mount
- filesystem.nffs.basic.gc
- filesystem.nffs.basic.gc_on_oom
- filesystem.nffs.basic.incomplete_block
- filesystem.nffs.basic.large_write
- filesystem.nffs.basic.long_filename
- filesystem.nffs.basic.lost_found
- filesystem.nffs.basic.many_children
- filesystem.nffs.basic.mkdir
- filesystem.nffs.basic.open
- filesystem.nffs.basic.overwrite_many
- filesystem.nffs.basic.overwrite_one
- filesystem.nffs.basic.overwrite_three
- filesystem.nffs.basic.overwrite_two
- filesystem.nffs.basic.read
- filesystem.nffs.basic.readdir
- filesystem.nffs.basic.rename
- filesystem.nffs.basic.split_file
- filesystem.nffs.basic.unlink
- filesystem.nffs.basic.wear_level
- filesystem.nffs.cache.append
- filesystem.nffs.cache.corrupt_block
- filesystem.nffs.cache.corrupt_scratch
- filesystem.nffs.cache.fs_mount
...
- filesystem.nffs.cache.split_file
- filesystem.nffs.cache.unlink
- filesystem.nffs.cache.wear_level
- filesystem.nffs.large.append
- filesystem.nffs.large.corrupt_block
- filesystem.nffs.large.corrupt_scratch
...
- filesystem.nffs.large.split_file
- filesystem.nffs.large.unlink
- filesystem.nffs.large.wear_level
- filesystem.nffs.performance.append
- filesystem.nffs.performance.corrupt_block
...
- filesystem.nffs.performance.unlink
- filesystem.nffs.performance.wear_level
92 total.
(so it was repeating ALL the subcases for eatch main testcase)
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
103 lines
2.7 KiB
C
103 lines
2.7 KiB
C
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
* to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance
|
|
* with the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <fs.h>
|
|
#include <nffs/nffs.h>
|
|
#include "nffs_test_utils.h"
|
|
#include <ztest.h>
|
|
#include <ztest_assert.h>
|
|
|
|
void test_mkdir(void)
|
|
{
|
|
struct fs_file_t file;
|
|
int rc;
|
|
|
|
rc = nffs_format_full(nffs_current_area_descs);
|
|
zassert_equal(rc, 0, "cannot format nffs");
|
|
|
|
rc = fs_mkdir(NFFS_MNTP"/a/b/c/d");
|
|
zassert_equal(rc, -ENOENT, "cannot create directory");
|
|
|
|
rc = fs_mkdir("asdf");
|
|
zassert_equal(rc, -EINVAL, "cannot create directory");
|
|
|
|
rc = fs_mkdir(NFFS_MNTP"/a");
|
|
zassert_equal(rc, 0, "cannot create directory");
|
|
|
|
rc = fs_mkdir(NFFS_MNTP"/a/b");
|
|
zassert_equal(rc, 0, "cannot create directory");
|
|
|
|
rc = fs_mkdir(NFFS_MNTP"/a/b/c");
|
|
zassert_equal(rc, 0, "cannot create directory");
|
|
|
|
rc = fs_mkdir(NFFS_MNTP"/a/b/c/d");
|
|
zassert_equal(rc, 0, "cannot create directory");
|
|
|
|
rc = fs_open(&file, NFFS_MNTP"/a/b/c/d/myfile.txt");
|
|
zassert_equal(rc, 0, "cannot open file");
|
|
|
|
rc = fs_close(&file);
|
|
zassert_equal(rc, 0, "cannot close file");
|
|
|
|
struct nffs_test_file_desc *expected_system =
|
|
(struct nffs_test_file_desc[]) { {
|
|
.filename = "",
|
|
.is_dir = 1,
|
|
.children = (struct nffs_test_file_desc[]) { {
|
|
.filename = "a",
|
|
.is_dir = 1,
|
|
.children = (struct nffs_test_file_desc[]) { {
|
|
.filename = "b",
|
|
.is_dir = 1,
|
|
.children = (struct nffs_test_file_desc[]) { {
|
|
.filename = "c",
|
|
.is_dir = 1,
|
|
.children = (struct nffs_test_file_desc[]) { {
|
|
.filename = "d",
|
|
.is_dir = 1,
|
|
.children = (struct nffs_test_file_desc[]) { {
|
|
.filename = "myfile.txt",
|
|
.contents = NULL,
|
|
.contents_len = 0,
|
|
}, {
|
|
.filename = NULL,
|
|
} },
|
|
}, {
|
|
.filename = NULL,
|
|
} },
|
|
}, {
|
|
.filename = NULL,
|
|
} },
|
|
}, {
|
|
.filename = NULL,
|
|
} },
|
|
}, {
|
|
.filename = NULL,
|
|
} },
|
|
} };
|
|
|
|
nffs_test_assert_system(expected_system, nffs_current_area_descs);
|
|
}
|