Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2019-12-29 08:13:59 +0300
committerChristopher Haster <chaster@utexas.edu>2019-12-29 08:43:02 +0300
commitf42e00770915d36e7118b57cbc19531fa38ad9a2 (patch)
tree0586ac5536382b212bcf4baac910be5876011c08 /lfs_util.h
parentce2c01f098f4d2b9479de5a796c3bb531f1fe14c (diff)
Created initial implementation of revamped test.py
This is the start of reworking littlefs's testing framework based on lessons learned from the initial testing framework. 1. The testing framework needs to be _flexible_. It was hacky, which by itself isn't a downside, but it wasn't _flexible_. This limited what could be done with the tests and there ended up being many workarounds just to reproduce bugs. The idea behind this revamped framework is to separate the description of tests (tests/test_dirs.toml) and the running of tests (scripts/test.py). Now, with the logic moved entirely to python, it's possible to run the test under varying environments. In addition to the "just don't assert" run, I'm also looking to run the tests in valgrind for memory checking, and an environment with simulated power-loss. The test description can also contain abstract attributes that help control how tests can be ran, such as "leaky" to identify tests where memory leaks are expected. This keeps test limitations at a minimum without limiting how the tests can be ran. 2. Multi-stage-process tests didn't really add value and limited what the testing environment. Unmounting + mounting can be done in a single process to test the same logic. It would be really difficult to make this fail only when memory is zeroed, though that can still be caught by power-resilient tests. Requiring every test to be a single process adds several options for test execution, such as using a RAM-backed block device for speed, or even running the tests on a device. 3. Added fancy assert interception. This wasn't really a requirement, but something I've been wanting to experiment with for a while. During testing, scripts/explode_asserts.py is added to the build process. This is a custom C-preprocessor that parses out assert statements and replaces them with _very_ verbose asserts that wouldn't normally be possible with just C macros. It even goes as far as to report the arguments to strcmp, since the lack of visibility here was very annoying. tests_/test_dirs.toml:186:assert: assert failed with "..", expected eq "..." assert(strcmp(info.name, "...") == 0); One downside is that simply parsing C in python is slower than the entire rest of the compilation, but fortunately this can be alleviated by parallelizing the test builds through make. Other neat bits: - All generated files are a suffix of the test description, this helps cleanup and means it's (theoretically) possible to parallelize the tests. - The generated test.c is shoved base64 into an ad-hoc Makefile, this means it doesn't force a rebuild of tests all the time. - Test parameterizing is now easier. - Hopefully this framework can be repurposed also for benchmarks in the future.
Diffstat (limited to 'lfs_util.h')
-rw-r--r--lfs_util.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/lfs_util.h b/lfs_util.h
index 80fab55..a131a3f 100644
--- a/lfs_util.h
+++ b/lfs_util.h
@@ -51,28 +51,28 @@ extern "C"
// Logging functions
#ifdef LFS_YES_TRACE
#define LFS_TRACE(fmt, ...) \
- printf("lfs_trace:%d: " fmt "\n", __LINE__, __VA_ARGS__)
+ printf("%s:%d:trace: " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
#else
#define LFS_TRACE(fmt, ...)
#endif
#ifndef LFS_NO_DEBUG
#define LFS_DEBUG(fmt, ...) \
- printf("lfs_debug:%d: " fmt "\n", __LINE__, __VA_ARGS__)
+ printf("%s:%d:debug: " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
#else
#define LFS_DEBUG(fmt, ...)
#endif
#ifndef LFS_NO_WARN
#define LFS_WARN(fmt, ...) \
- printf("lfs_warn:%d: " fmt "\n", __LINE__, __VA_ARGS__)
+ printf("%s:%d:warn: " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
#else
#define LFS_WARN(fmt, ...)
#endif
#ifndef LFS_NO_ERROR
#define LFS_ERROR(fmt, ...) \
- printf("lfs_error:%d: " fmt "\n", __LINE__, __VA_ARGS__)
+ printf("%s:%d:error: " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
#else
#define LFS_ERROR(fmt, ...)
#endif