I've noticed that on my local CI test platform, one of my tests is failing and I'm at a loss as to why. It's intermittent, but it fails far more often than not.

Here's the TAP output up until the failure is produced:

pi@pi-test:~/repos/rpi-wiringpi $ prove -v t/75-serial.t t/75-serial.t .. ok 1 - An object of class 'RPi::Serial' isa 'RPi::Serial' ok 2 - putc() and getc() ok not ok 3 - puts() and gets() ok # Failed test 'puts() and gets() ok' # at t/75-serial.t line 32. # got: 'hello, world!' # expected: 'hello, world!'

Notice how the got and expected are identical. What am I missing here?

The test is writing a string to, and then reading the string back from a serial interface. Here's the test code if it helps:

use strict; use warnings; use lib 't/'; use RPiTest qw(check_pin_status); use RPi::WiringPi; use RPi::Const qw(:all); use Test::More; my $mod = 'RPi::WiringPi'; if (! $ENV{RPI_SERIAL}){ plan skip_all => "RPI_SERIAL environment variable not set\n"; } if (! $ENV{PI_BOARD}){ $ENV{NO_BOARD} = 1; plan skip_all => "Not on a Pi board\n"; } my $pi = $mod->new; my $s = $pi->serial("/dev/ttyS0", 115200); isa_ok $s, 'RPi::Serial'; $s->putc(254); is $s->getc, 254, "putc() and getc() ok"; $s->puts("hello, world!"); # FAILING TEST IS BELOW is $s->gets(13), "hello, world!", "puts() and gets() ok"; $pi->cleanup; check_pin_status(); done_testing();

In reply to Unit test failing but "got" and "expected" are equal by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.