1

I have 2 files containing test number, test name, seed value, status (passed or failed), and a test type (mcu or bfm). The only 2 columns I'm focused on are the test names and status. I ran some tests which are a subset of my total tests and generated a log file with the above format and wanted to do a diff to see if the status of the tests have changed; a tkdiff won't work since the files aren't the same. How can I do a comparison to see if the diff of my subset of tests against the main test file? I would do it by hand except there's over 400 tests.

Example:

Subset tests

|---------|------------------------------------------------------------------------------|-------|-----------|------------|
|Sr.Num   |test_name                                                                     |seed   |Status     |XDATA MASTER|
|---------|------------------------------------------------------------------------------|-------|-----------|------------|
|        1|                                                     usb3_bootrom_flex_connect|      1|     PASSED|         MCU|
|        2|                                                       usb3_XTAL_25MHZ_bootrom|      1|     PASSED|         MCU|

All tests file

|---------|------------------------------------------------------------------------------|-------|-----------|------------|
|Sr.Num   |test_name                                                                     |seed   |Status     |XDATA MASTER|
|---------|------------------------------------------------------------------------------|-------|-----------|------------|
|       50|                                                     usb3_bootrom_flex_connect|      1|     FAILED|         MCU|
|      200|                                                       usb3_XTAL_25MHZ_bootrom|      1|     FAILED|         MCU|

Output file:

usb3_bootrom_flex_connect New: PASSED Old: FAILED usb3_XTAL_25MHZ_bootrom New: PASSED Old: FAILED

Test subset: https://pastebin.com/9rWAupaJ

All tests: https://pastebin.com/cVpzY8C8

I just want to see if the subset tests have changed in status. It doesn't matter how I do this really. If I could do it with a tkdiff I would.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Javia1492
  • 113

1 Answers1

2

Maybe you could do something with a lot of cutting and grepping and tkdiff, but you can use a single sed script to do the job:

sed -n -e '3{:a' -e 'n;s/.* \([^|]*\)| *[0-9]*| *\([A-Z]*\).*/\1 \2/;H;ta}
  G;s/^|[^|]*| *\([^|]*\)| *[0-9]*| *\([A-Z]*\).*\1 \([A-Z]*\).*/\1  New: \2  Old: \3/p' tests.new tests.old

The first line collects the new test results in the hold space, the second line scans the lines of the old tests, compares the test name with those in the hold space and prints a line for a match.

For a detailed explanation of that principle see this answer.

Please note that for larger files of new tests this script may get slow because of the regular expression with back reference.

Philippos
  • 13,453