46#ifdef DEBUG_TEST_DIRECTORY_TREE
47 #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
60int test_directory_tree::execute()
88 LOG(
astring(
"Scanning directory tree at \"") + path +
"\"");
89 LOG(
astring(
"Using pattern-match \"") + pattern +
"\"");
92 ASSERT_TRUE(dir.good(),
"directory_tree construction should succeed and be readable.");
107 for (
int i = 0; i <
files.length(); i++) names += files[i] +
" ";
120 LOG(
astring(
"Finished scan on directory tree at \"") + path +
"\"");
132 LOG(
astring(
"Self-comparing directory tree at \"") + path +
"\"");
133 LOG(
astring(
"Using pattern-match \"") + pattern +
"\"");
135 LOG(
"reading tree 1.");
137 ASSERT_TRUE(dir.good(),
"the directory should be readable for self-compare");
138 LOG(
"done reading tree 1.");
141 LOG(
"reading tree 2.");
143 ASSERT_TRUE(dir2.good(),
"the directory should read the second time fine too");
144 LOG(
"done reading tree 2.");
146 LOG(
"started comparing the two trees.");
149 LOG(
"finished comparing the two trees.");
151LOG(
"#### diffs found...");
160 LOG(
astring(
"Calculating sums for tree at \"") + path +
"\"");
161 LOG(
astring(
"Using pattern-match \"") + pattern +
"\"");
163 LOG(
"reading tree 1.");
165 ASSERT_TRUE(dir.good(),
"the directory should be readable for checksums");
168 LOG(
"reading tree 2.");
170 ASSERT_TRUE(dir2.good(),
"checksummer should be able to read second time also");
172 LOG(
"calculating checksums for tree 1.");
175 LOG(
"calculating checksums for tree 2.");
178 LOG(
"comparing the two trees.");
186 ASSERT_FALSE(diffs.
elements(),
"no checksummer differences should be seen for identical directories");
191 LOG(
astring(
"Reading tree for packing at \"") + path +
"\"");
192 LOG(
astring(
"Using pattern-match \"") + pattern +
"\"");
194 LOG(
"reading tree.");
196 ASSERT_TRUE(dir.good(),
"packer directory should be read");
198 LOG(
"calculating checksums for tree.");
200 LOG(
"done calculating checksums for tree.");
202 LOG(
"packing the tree.");
204 int size_packed = dir.packed_size();
205 dir.pack(packed_form);
209 LOG(
"unpacking the tree.");
211 ASSERT_TRUE(dir2.
unpack(packed_form),
"second tree can be unpacked from the first");
213 LOG(
"comparing the two trees.");
217 LOG(
"finished comparing the two trees.");
227LOG(
"reading tree to test making directories");
229 ASSERT_TRUE(dir.good(),
"makedirs test directory reading");
231 LOG(
astring(
"will write to tmp in ") + tmpdir);
235LOG(
"what happened with that? did it work? merely rhetorical, since we need more code here.");
249ASSERT_FALSE(kid,
"removing temporary files after test");
264 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)