diff --git a/README.txt b/README.txt index 69dca08b140ebf34debc9a9986e5260a976b8914..b3dafc4fff3764ba5fe65d3e857b89a4c0441c40 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ README -Program: "fact" +Programme: "fact" ## TABLE OF CONTENTS * [0. General Info] @@ -28,21 +28,45 @@ the programme "fact" can be updated by changing the constant MAX_NO_THREADS ## 1. Installation Steps -The programme directory includes 4 files: -a. the C programme file "fact.c" -b. the "Makefile" with three basic "make" operations: - - "make fact" compiles "fact.c" and create the executable "fact" - - "make test" compiles "fact.c" and performs the unit tests +The programme directory includes several files, a list is provided herebelow: +a. The C programme file "fact.c" +b. The "Makefile" with three basic "make" operations: + - "make fact" compiles "fact.c" and create the executable "fact" + (Note: in Windows we have "fact.exe") + - "make test" compiles "Fact_UnitTest.c", the unit tests are performed + with the command "make cunit", (Note: in Windows we have "Fact_UnitTest.exe"). - "make clean" deletes the executable "fact", all the output files with the prefix "out" (e.g. output.txt, out_result.txt, out.txt, ...) and the files produced by unit tests. -c. the input file "example_input.txt" contains the numbers to be factorized (one + To these basic operations more tags are provided, in particular: + - "make cunit" prepares the environment and execute the Cunit test + on the main "fact" functions. The result is redirected into the file + "Cunit_test_file.txt" + - "make valgrind" executes the tool valgrind on "fact" and the results + are redirected into the file "valgrind_fact.txt" + - "make cppcheck" executes the tool cppcheck on "fact" and the results + are redirected into the file "cppcheck_fact.txt". + - "make valgrind_cunit" executes the tool valgrind on "Fact_UnitTest" + and the results are redirected into the file "valgrind_cunit.txt". + - "make cppcheck_cunit" executes the tool cppcheck on "Fact_UnitTest" + and the results are redirected into the file "cppcheck_cunit.txt". + +c. The input file "example_input.txt" contains the numbers to be factorized (one per line). This file allows to verify the correct calculation by comparing the ouput with the results stored into another file: "example_output.txt". Note: "example_input.txt" and "example_output.txt" are the files provided by the project specification (at the initial project stage). These files are not deleted by "make clean". +d. The input file "incorrect_numbers.txt" contains numbers out of the scope of the + programme fact (e.g. numbers < 2). This file can be used for testing purposes. + +e. The file "Fact_UnitTest.c" contains the unit tests code exploiting the facility + of the "CUnit" library. + +f. The files "valgrind_fact.txt", "cppcheck_fact.txt" and "Cunit_test_file.txt" +are the output of valgrind, cppcheck tools and CUnit tests. + ## 2. Programme General Architecture @@ -123,7 +147,7 @@ As drawn in the scheme of the "Programme General Architecture" the programme because the function "is_prime" is more cpu time demanding. -> bool is_prime(unsigned long nbr) This function determines if a number is prime. To speed up the - computation, the algorithm is based on the "Crible d'Ératosthène" + computation, the algorithm is based on the "Crible d'Ératosthène" (see "https://fr.wikipedia.org/wiki/Nombre_premier") -> bool is_div(unsigned long numbr, unsigned long i) This function exploits the operator "%" (modulo) to determine if @@ -131,7 +155,9 @@ As drawn in the scheme of the "Programme General Architecture" the programme Finally, the "main" is charged to check the programme arguments correctness (argc and argv[]) and, in case of error, a message is provided to -the user. The "main" performs the following sequential actions: +the user. The "fact" programme cannot calculate numbers < 2, a warning is +provided. +The "main" performs the following sequential actions: - the start of cpu time, - the input and output files are opened, in case of error this is reported, - the mutex is initialised,