Crinit -- Configurable Rootfs Init
utest-file-series-from-dir.c File Reference

(2023-10-16, commit: 49337e0)

Implementation of the crinitFileSeriesFromDir() unit test group. More...

#include "utest-file-series-from-dir.h"
#include <dirent.h>
#include <sys/types.h>
#include "common.h"
#include "fseries.h"
#include "unit_test.h"
Include dependency graph for utest-file-series-from-dir.c:

Functions

int crinitInitFileSeries (crinitFileSeries_t *fse, size_t numElements, const char *baseDir)
 
void crinitDestroyFileSeries (crinitFileSeries_t *fse)
 
void crinitFreeScandirList (struct dirent **scanList, int size)
 
int main (void)
 

Detailed Description

Implementation of the crinitFileSeriesFromDir() unit test group.

Function Documentation

◆ crinitDestroyFileSeries()

void crinitDestroyFileSeries ( crinitFileSeries_t fse)

Frees memory associated with an crinitFileSeries_t.

Parameters
fseThe crinitFileSeries_t whose memory shall be deallocated.

◆ crinitFreeScandirList()

void crinitFreeScandirList ( struct dirent **  scanList,
int  size 
)

Free return pointer(s) from scandir().

Will free everything, scandir() has allocated according to the scandir(3) man page.

◆ crinitInitFileSeries()

int crinitInitFileSeries ( crinitFileSeries_t fse,
size_t  numElements,
const char *  baseDir 
)

Initialize an crinitFileSeries_t with a given number of empty pointers.

Sets initial state and then uses crinitResizeFileSeries() internally to allocate space for the pointers.

Parameters
fseThe crinitFileSeries_t to initialize.
numElementsThe number of pointers in crinitFileSeries_t::fnames to allocate. No memory for the backing string is allocated at this point.
baseDirBase directory of the new file series to be set.
Returns
0 on success, -1 otherwise.

◆ main()

int main ( void  )

Runs the unit test group for crinitFileSeriesFromDir using the cmocka API.