111 lines
3.8 KiB
C
111 lines
3.8 KiB
C
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
|
|
|
/*=======Test Runner Used To Run Each Test Below=====*/
|
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
|
{ \
|
|
Unity.CurrentTestName = #TestFunc; \
|
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
|
Unity.NumberOfTests++; \
|
|
if (TEST_PROTECT()) { \
|
|
setUp(); \
|
|
TestFunc(); \
|
|
} \
|
|
if (TEST_PROTECT()) { \
|
|
tearDown(); \
|
|
} \
|
|
UnityConcludeTest(); \
|
|
}
|
|
|
|
/*=======Automagically Detected Files To Include=====*/
|
|
#include "unity.h"
|
|
#include <setjmp.h>
|
|
#include <dirent.h>
|
|
|
|
#include "user_fs.h"
|
|
#include "lisa_sdmmc.h"
|
|
#include "IOMuxManager.h"
|
|
|
|
void setUp(void)
|
|
{
|
|
}
|
|
|
|
void tearDown(void)
|
|
{
|
|
}
|
|
|
|
/*=======Test Reset Option=====*/
|
|
void resetTest(void);
|
|
void resetTest(void)
|
|
{
|
|
tearDown();
|
|
setUp();
|
|
}
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
void test_opendir_func(void)
|
|
{
|
|
DIR *dir = opendir("/SD:/");
|
|
TEST_ASSERT_NOT_NULL(dir);
|
|
closedir(dir);
|
|
}
|
|
|
|
void test_readdir_func(void)
|
|
{
|
|
DIR *dir = opendir("/SD:/");
|
|
TEST_ASSERT_NOT_NULL(dir);
|
|
struct dirent *entry = readdir(dir);
|
|
TEST_ASSERT_NOT_NULL(entry);
|
|
closedir(dir);
|
|
}
|
|
|
|
void test_loop_readdir_not_infinite(void)
|
|
{
|
|
DIR *dir = opendir("/SD:/");
|
|
TEST_ASSERT_NOT_NULL(dir);
|
|
struct dirent *entry = readdir(dir);
|
|
int count = 0;
|
|
while (entry != NULL && count < 64) {
|
|
printf("d_name: %s, d_type: %d\n", entry->d_name, entry->d_type);
|
|
count++;
|
|
entry = readdir(dir);
|
|
}
|
|
if (count == 64) {
|
|
printf("[WARN] Too many entries or possible infinite loop!\n");
|
|
TEST_FAIL();
|
|
}
|
|
closedir(dir);
|
|
}
|
|
|
|
void test_closedir_func(void)
|
|
{
|
|
DIR *dir = opendir("/SD:/");
|
|
TEST_ASSERT_NOT_NULL(dir);
|
|
closedir(dir);
|
|
}
|
|
|
|
/*=======MAIN=====*/
|
|
int main(void)
|
|
{
|
|
/* Configure SDMMC pins (same as lisa_disk test) */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 6, CSK_IOMUX_FUNC_ALTER15); /* CLK */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 7, CSK_IOMUX_FUNC_ALTER15); /* CMD */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 5, CSK_IOMUX_FUNC_ALTER15); /* DAT0 */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 4, CSK_IOMUX_FUNC_ALTER15); /* DAT1 */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 9, CSK_IOMUX_FUNC_ALTER15); /* DAT2 */
|
|
IOMuxManager_PinConfigure(CSK_IOMUX_PAD_A, 8, CSK_IOMUX_FUNC_ALTER15); /* DAT3 */
|
|
|
|
user_fs_init();
|
|
|
|
printf("user fs init complete\n");
|
|
|
|
UnityBegin("test/dirent_func/test_dirent.c");
|
|
RUN_TEST(test_opendir_func, __LINE__);
|
|
RUN_TEST(test_readdir_func, __LINE__);
|
|
RUN_TEST(test_loop_readdir_not_infinite, __LINE__);
|
|
RUN_TEST(test_closedir_func, __LINE__);
|
|
return (UnityEnd());
|
|
}
|