Skip to main content

Lab 14: File comparison

One of the important uses of the VILLASnode toolbox is the comparison of a list of files.

The following command can be used to compare the files:

villas-test-cmp [OPTIONS] FILE1 FILE2 ... FILEn

Where options refers to one or more of the following:

OptionDescription
-d LVLAdjust the debug level
-e EPSSet epsilon for floating point comparisons to EPS
-vIgnore data values
-TIgnore timestamp
-sIgnore sequence no
-F fmtFile format for all files
-t DTThe data-type format string
-hshow this usage information
-Vshow the version of the tool

In this example we shall use this tool to compare two files. In the first terminal execute the following command:

villas signal sine > file_send.dat
villas pipe lab3.conf villas_node1 < file_send.dat

Open a second terminal to record the data being sent into another file. Execute the following command:

villas pipe -x lab3.conf villas_node1 > file_receive.dat

Now run the following command to compare the two files. He we ignore the timestamps since it will be different in both the cases:

villas test-cmp -T file_send.dat file_receive.dat

Following return codes are obtained based on the similarity between the two files:

CodeDescription
0files are equal
1file length not equal
2sequence no not equal
3timestamp not equal
4number of values is not equal
5data is not equal

Following command can be used to determine the return codes:

echo $?

Since the files are equal in this example we get 0 as the return code.