mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
* toolbox, gui: fixes for compressed icon handling * ufbt: fixes for generated vscode project * scripts: increased max dimensions for image converter * icon type changes * linter fixes; api sync * gui: docs fix * toolbox: fixed potential decoder buffer overflow * minor cleanup * fbt: sdk: suppressed deprecation warnings in API table * toolbox: compress: added unit tests vscode: now installs resources for unit_tests unit_tests: now loads subghz region data * toolbox: compress: review fixes, pt 1 * compress: now passes decoder buffer size as constructor argument; auto-resize decoder buffer; crash on failed icon decompression * PVS fixes * pvs fixes, pt2 * doxygen fixes * investigating unit test failures * investigating unit test failures * investigating unit test failures * investigating unit test failures * investigating unit test failures * UnitTests: move all tests into plugins, brakes testing * UnitTests: add plugin API and update plugin entrypoints * UniTests: Test runner that works with plugins * fbt: extra filtering for extapps to include in build * UnitTests: filter tests by name * loader: restored API table for unit_test build config * Add various missing symbols to API table * UnitTest: fail on plugin load error * UnitTests: cleanup plugin api and reporting * unit_tests: composite resolver * UnitTests: remove unused declaration * unit_tests, nfc: moved mock nfc implementation to libnfc * unit_tests: api: removed redundant #define * toolbox: compress: removed size_hint for icons; triggering furi_check on oversized icons * gui: icon, icon_animation: removed size hit APIs * Format Sources. Cleanup code. * loader: refuse to start .fal as app * toolbox: compress: fixed memory corruption in operations with small destination buffer; added unit tests for that case * unit_tests: proper test skipping; better selective test interface * unit_tests: moved 'loading' logging to proper location Co-authored-by: あく <alleteam@gmail.com>
78 lines
2.8 KiB
C
78 lines
2.8 KiB
C
#include <furi.c>
|
|
#include "../test.h"
|
|
#include <update_util/resources/manifest.h>
|
|
|
|
#define TAG "Manifest"
|
|
|
|
MU_TEST(manifest_type_test) {
|
|
mu_assert(ResourceManifestEntryTypeUnknown == 0, "ResourceManifestEntryTypeUnknown != 0\r\n");
|
|
mu_assert(ResourceManifestEntryTypeVersion == 1, "ResourceManifestEntryTypeVersion != 1\r\n");
|
|
mu_assert(
|
|
ResourceManifestEntryTypeTimestamp == 2, "ResourceManifestEntryTypeTimestamp != 2\r\n");
|
|
mu_assert(
|
|
ResourceManifestEntryTypeDirectory == 3, "ResourceManifestEntryTypeDirectory != 3\r\n");
|
|
mu_assert(ResourceManifestEntryTypeFile == 4, "ResourceManifestEntryTypeFile != 4\r\n");
|
|
}
|
|
|
|
MU_TEST(manifest_iteration_test) {
|
|
bool result = true;
|
|
size_t counters[5] = {0};
|
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
ResourceManifestReader* manifest_reader = resource_manifest_reader_alloc(storage);
|
|
do {
|
|
// Open manifest file
|
|
if(!resource_manifest_reader_open(manifest_reader, EXT_PATH("unit_tests/Manifest_test"))) {
|
|
result = false;
|
|
break;
|
|
}
|
|
|
|
// Iterate forward
|
|
ResourceManifestEntry* entry_ptr = NULL;
|
|
while((entry_ptr = resource_manifest_reader_next(manifest_reader))) {
|
|
FURI_LOG_D(TAG, "F:%u:%s", entry_ptr->type, furi_string_get_cstr(entry_ptr->name));
|
|
if(entry_ptr->type > 4) {
|
|
mu_fail("entry_ptr->type > 4\r\n");
|
|
result = false;
|
|
break;
|
|
}
|
|
counters[entry_ptr->type]++;
|
|
}
|
|
if(!result) break;
|
|
|
|
// Iterate backward
|
|
while((entry_ptr = resource_manifest_reader_previous(manifest_reader))) {
|
|
FURI_LOG_D(TAG, "B:%u:%s", entry_ptr->type, furi_string_get_cstr(entry_ptr->name));
|
|
if(entry_ptr->type > 4) {
|
|
mu_fail("entry_ptr->type > 4\r\n");
|
|
result = false;
|
|
break;
|
|
}
|
|
counters[entry_ptr->type]--;
|
|
}
|
|
} while(false);
|
|
|
|
resource_manifest_reader_free(manifest_reader);
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
|
mu_assert(counters[ResourceManifestEntryTypeUnknown] == 0, "Unknown counter != 0\r\n");
|
|
mu_assert(counters[ResourceManifestEntryTypeVersion] == 0, "Version counter != 0\r\n");
|
|
mu_assert(counters[ResourceManifestEntryTypeTimestamp] == 0, "Timestamp counter != 0\r\n");
|
|
mu_assert(counters[ResourceManifestEntryTypeDirectory] == 0, "Directory counter != 0\r\n");
|
|
mu_assert(counters[ResourceManifestEntryTypeFile] == 0, "File counter != 0\r\n");
|
|
|
|
mu_assert(result, "Manifest forward iterate failed\r\n");
|
|
}
|
|
|
|
MU_TEST_SUITE(manifest_suite) {
|
|
MU_RUN_TEST(manifest_type_test);
|
|
MU_RUN_TEST(manifest_iteration_test);
|
|
}
|
|
|
|
int run_minunit_test_manifest(void) {
|
|
MU_RUN_SUITE(manifest_suite);
|
|
return MU_EXIT_CODE;
|
|
}
|
|
|
|
TEST_API_DEFINE(run_minunit_test_manifest)
|