Skip to content

Compare logs for verification #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 31, 2017

Conversation

mazimkhan
Copy link

@mazimkhan mazimkhan commented Dec 5, 2016

@mazimkhan
Copy link
Author

@sbutcher-arm @andresag01 Please review.

@mazimkhan
Copy link
Author

mazimkhan commented Dec 12, 2016

@sbutcher-arm @andresag01

  • moved logs to tests directory.
  • Added missing DONE in tests/benchmark.log
  • Created tests/README.md

please review and merge.

Copy link

@andresag01 andresag01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in general this is progressing in the right direction but I think there are a few issues:

  • The patterns should be tidied up according to the output. For instance, in benchmark matching a specific number of space characters may cause problems, and the hashing output may match a failed run.
  • I think the documentation gives too much detail in terms of example usages of htrun. I would prefer this to just explain the rationale of the .log files, how to use them and point to the htrun docs for more info.
  • There are a few typos in the README and is difficult to understand in places.

plaintext message: [0-9a-fA-F]*
ciphertext: [0-9a-fA-F]*
decrypted: [0-9a-fA-F]*
DONE

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of CRLF (\r\n) in these .log files. Is this necessary? If not, could we simple use \n like the rest of the project?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are because the template is made out of a serial output. It is not hand made. We can remove \r for readability but that will require manual effort of making the logs readable.

ECDHE-Curve25519 :\s*\d+ ms/handshake
ECDH-secp384r1 :\s*\d+ ms/handshake
ECDH-secp256r1 :\s*\d+ ms/handshake
ECDH-Curve25519 :\s*\d+ ms/handshake

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that all these lines have a fixed number of spaces between the algorithm they are benchmarking and the : character. Perhaps it would be more robbust to use something like \s+?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that if the code is suppose to change this space. Since it is fixed space we don't need to worry about it. Idea is to keep this approach simple and stupid and only put effort in regex for complex patterns.

Also one thing to bear in mind is that htrun first tries to compare a line character by character. In this case a line with special characters will also match. But if this comparison fails then htrun tries to use the line form the template as a regex. Hence if we remove any character from the template line (i.e. treating it as a regex) then we have to be careful of the characters in the line (regex). As characters like ()<>.*+\ are used as special meaning chars in the regex. They would then need to be escaped.


## How to create templated log

The idea is to check that repeated execution of the examples produce same serial output. An example produces serial output when code contains ```printf``` statements. Serial output may change for ligitimate reasons like use of random data or data and time stamps. Thats why the log is converted to a template. This means that either the text/lines that differ in every execution are removed or they are converted into regular expressions. See the example below:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first sentence says:

repeated execution of the examples produce same serial output

However, I thought that the idea is to check whether the output of an application matches an expected pattern.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: ligitimate -> legitimate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest: reasons like use of random data or data and time stamps -> reasons such as the use of random data or time stamps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thing in the sentence Thats why the log should be That's why the log (notice the ')


```

Please observe above that all the lines that have data that changes from execution to execution (on right) have been removed. It makes it possible htrun to compare these logs. htrun matches lines from the compare log (on left) one by one. It keeps on looking for a line until it matches. Once matched it moves on to match the next line. If it finds all lines from the compare log in the target serial output stream. Then it halts and passes the examples.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest: Please observe above that all the lines that have data that changes from execution to execution (on right) have been removed. It makes it possible htrun to compare these logs -> Please observe above that all the lines that have data that changes from execution to execution (on right) have been removed enbling htrun to compare the logs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest: Then it halts and passes the examples. -> Then it halts and the test passes.


Hello world! Hello world!

```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the rationale of the README is to provide some insight regarding the .log files. I think that having a short example is appropriate, however, I consider that the examples of htrun usage in this README are a bit too extensive and better suited to the htrun documentation itself. I suggest removing the tls-client example and simply leaving a fragment of the benchmark log comparison below (perhaps 4-5 lines). What are your thoughts @mazimkhan?

Copy link
Author

@mazimkhan mazimkhan Jan 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this example as it illustrates the one useful way of making a template log that is by removing random data.
We don't need to add anymore examples as these two cover the current approaches we take.

@@ -0,0 +1,4 @@
plaintext message: [0-9a-fA-F]*
ciphertext: [0-9a-fA-F]*
decrypted: [0-9a-fA-F]*
Copy link

@andresag01 andresag01 Jan 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this regular expression is a little too simple. This will match something like:

plaintext message: 
ciphertext: 
decrypted: 

Which is not correct output because there is no hash value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed [0-9a-fA-F]* -> [0-9a-fA-F]+.

Copy link

@andresag01 andresag01 Jan 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my previous message was a bit misleading because I thought this was hashing instead of authcrypt. I still think bits of it do not need a complex regexp. For example the plaintext message and the decrypted message must be the same value (otherwise there is a serious problem) and is hardcoded in the example.

@mazimkhan
Copy link
Author

@andresag01 Incorporated code review comments. Please review.

@andresag01 andresag01 dismissed their stale review January 27, 2017 16:37

This review is no longer valid. Changes have been made to the PR since then.

@andresag01
Copy link

@Azim: As discussed before, could you please remove the \r from the pattern files? Also, it seems that there are some issues with htrun in Linux.

@mazimkhan
Copy link
Author

@andresag01 good find. Removed carriage return from the logs and it works for me now. Please try again.

@andresag01
Copy link

@mazimkhan: Thanks for fixing the issues previously found. However, I am having difficulties trying to test these log files as mbedhtrun is not able to properly flash applications onto the target reliably in Linux. I get the following error:

[1485874580.84][COPY][INF] Waiting for mount point '/media/andama01/MBED' to be ready...
..............................cp: cannot create regular file '/media/andama01/MBED/benchmark.bin': No such file or directory
[1485874588.56][COPY][ERR] [ret=1] Command: ['cp', 'BUILD/K64F/GCC_ARM/benchmark.bin', '/media/andama01/MBED/benchmark.bin']

Furthermore, if I manually mount the device and then run mbedhtrun then the program works in some cases but it fails in some other cases with the following error:

[1485874744.02][HTST][INF] test suite run finished after 60.09 sec...
[1485874744.02][HTST][ERR] Expected output [DONE] not received in log.
[1485874744.03][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1485874744.03][HTST][INF] CONN exited with code: 0
[1485874744.03][HTST][INF] Some events in queue
[1485874744.03][HTST][INF] stopped consuming events
[1485874744.03][HTST][INF] host test result(): None
[1485874744.03][HTST][WRN] missing __exit event from DUT
[1485874744.03][HTST][WRN] missing __exit_event_queue event from host test
[1485874744.03][HTST][ERR] missing __exit_event_queue event from host test and no result from host test, timeout...
[1485874744.03][HTST][INF] calling blocking teardown()
[1485874744.03][HTST][INF] teardown() finished
[1485874744.03][HTST][INF] {{result;timeout}}

@mazimkhan
Copy link
Author

mazimkhan commented Jan 31, 2017 via email

@andresag01
Copy link

I ran the test for each of the examples and it seems to work as expected.

@andresag01 andresag01 merged commit ebc8e32 into ARMmbed:master Jan 31, 2017
@simonbutcher simonbutcher changed the title Campare logs for verification Compare logs for verification Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants