43#define DEBUG_TEST_DIRECTORY_TREE
46#define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
56int test_directory_tree::execute()
89#ifdef DEBUG_TEST_DIRECTORY_TREE
90 log(
astring(
"Scanning directory tree at \"") + path +
"\"");
91 log(
astring(
"Using pattern-match \"") + pattern +
"\"");
95 ASSERT_TRUE(dir.good(),
"directory_tree construction should succeed and be readable.");
107#ifdef DEBUG_TEST_DIRECTORY_TREE
112 for (
int i = 0; i <
files.length(); i++) names += files[i] +
" ";
116#ifdef DEBUG_TEST_DIRECTORY_TREE
142 ASSERT_TRUE(dir.good(),
"the directory should be readable for self-compare");
147 ASSERT_TRUE(dir2.good(),
"the directory should read the second time fine too");
149 LOG(
"comparing the two trees.");
164 ASSERT_TRUE(dir.good(),
"the directory should be readable for checksums");
169 ASSERT_TRUE(dir2.good(),
"checksummer should be able to read second time also");
182 ASSERT_FALSE(diffs.
elements(),
"no checksummer differences should be seen for identical directories");
192 ASSERT_TRUE(dir.good(),
"packer directory should be read");
198 int size_packed = dir.packed_size();
199 dir.pack(packed_form);
204 ASSERT_TRUE(dir2.
unpack(packed_form),
"second tree can be unpacked from the first");
219LOG(
"reading tree to recreate");
221 ASSERT_TRUE(dir.good(),
"makedirs test directory reading");
223 LOG(
astring(
"will write to tmp in ") + tmpdir);
227LOG(
"what happened with that? did it work? merely rhetorical, since we need more code here.");
241ASSERT_FALSE(kid,
"removing temporary files after test");
256 return final_report();
The application_shell is a base object for console programs.
virtual int execute()=0
< retrieves the command line from the /proc hierarchy on linux.
application_shell()
constructs an application_shell to serve as the root of the program.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
int length() const
Returns the current length of the string.
A very common template for a dynamic array of bytes.
static astring get(const astring &variable_name)
looks up the "variable_name" in the current environment variables.
Outcomes describe the state of completion for an operation.
An object that traverses directory trees and provides a view of all files.
static bool current(dir_tree_iterator &scanning, filename &dir_name, structures::string_array &to_fill)
retrieves the information for the iterator's current location.
static bool compare_trees(const directory_tree &source, const directory_tree &target, filename_list &differences, file_info::file_similarity how_to_compare)
compares the tree in "source" with the tree in "target".
static bool depth(dir_tree_iterator &scanning, int &depth)
returns the current depth of the iterator.
@ prefix
prefix means that subnodes are processed after their parent.
virtual bool unpack(basis::byte_array &packed_form)
unpacks the directory_tree from a byte_array.
static void throw_out(dir_tree_iterator *&to_whack)
cleans up an iterator that was previously opened with start().
static bool next(dir_tree_iterator &scanning)
goes to the next filename in the "scanning" iterator.
@ EQUAL_CHECKSUM_TIMESTAMP_FILESIZE
basis::astring text_form(int max_lines=MAXINT32) const
max_lines is the maximum number of lines to print into the string.
Provides operations commonly needed on file names.
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
@ AWAIT_APP_EXIT
stays in the function until the launched application has exited.
static basis::un_int run(const basis::astring &app_name, const basis::astring &command_line, int flag, basis::un_int &child_id)
starts an application using the "app_name" as the executable to run.
int elements() const
the maximum number of elements currently allowed in this amorph.
An array of strings with some additional helpful methods.
static void split_lines(const basis::astring &input, basis::astring &output, int min_column=0, int max_column=79)
formats blocks of text for a maximum width.
static basis::astring indentation(int spaces)
Returns a string made of white space that is "spaces" long.
#define DEFINE_CLASS_NAME(objname)
Defines the name of a class by providing a couple standard methods.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Provides macros that implement the 'main' program of an application.
#define HOOPLE_MAIN(obj_name, obj_args)
options that should work for most unix and linux apps.
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
unsigned int un_int
Abbreviated name for unsigned integers.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
An extension to floating point primitives providing approximate equality.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
#define ASSERT_EQUAL(a, b, test_name)
#define ASSERT_TRUE(a, test_name)
#define ASSERT_FALSE(a, test_name)