Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SimpleNodeInfoMockUserFile.cxx
1
36#ifndef _POSIX_C_SOURCE
37#define _POSIX_C_SOURCE 200112L
38#endif
39
41
43
44#ifdef __FreeRTOS__
45openlcb::MockSNIPUserFile::MockSNIPUserFile(const char *user_name,
46 const char *user_description)
47 : snipData_{2}
48 , userFile_(MockSNIPUserFile::snip_user_file_path, &snipData_, false)
49{
50 str_populate(snipData_.user_name, user_name);
51 str_populate(snipData_.user_description, user_description);
52}
53
54openlcb::MockSNIPUserFile::~MockSNIPUserFile()
55{
56}
57
58#elif !defined(__WINNT__)
59#include "os/TempFile.hxx"
60
61openlcb::MockSNIPUserFile::MockSNIPUserFile(const char *user_name,
62 const char *user_description)
63 : userFile_(*TempDir::instance(), "snip_user_file")
64{
65 init_snip_user_file(userFile_.fd(), user_name, user_description);
66 HASSERT(userFile_.name().size() < sizeof(snip_user_file_path));
67 str_populate(snip_user_file_path, userFile_.name().c_str());
68}
69
70char openlcb::MockSNIPUserFile::snip_user_file_path[128] = "/dev/zero";
71
72openlcb::MockSNIPUserFile::~MockSNIPUserFile()
73{
74}
75
76#endif
77
This class creates a temporary directory for the test, and removes it when the test is done.
Definition TempFile.hxx:52
void str_populate(char(&dst)[N], const char *src)
Populates a character array with a C string.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
Definition macros.h:138
void init_snip_user_file(int fd, const char *user_name, const char *user_description)
Helper function for test nodes.