150476Speter// 215903Swosch// Automated Testing Framework (atf) 315903Swosch// 415903Swosch// Copyright (c) 2010 The NetBSD Foundation, Inc. 515903Swosch// All rights reserved. 615903Swosch// 715903Swosch// Redistribution and use in source and binary forms, with or without 815903Swosch// modification, are permitted provided that the following conditions 915903Swosch// are met: 1015903Swosch// 1. Redistributions of source code must retain the above copyright 1115903Swosch// notice, this list of conditions and the following disclaimer. 1215903Swosch// 2. Redistributions in binary form must reproduce the above copyright 1315903Swosch// notice, this list of conditions and the following disclaimer in the 14139761Skrion// documentation and/or other materials provided with the distribution. 1534678Sbde// 1623546Swosch// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 1723546Swosch// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 1823546Swosch// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1939161Sobrien// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2015903Swosch// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 2139161Sobrien// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2215903Swosch// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 2315903Swosch// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2415903Swosch// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 2515903Swosch// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2615903Swosch// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 2715903Swosch// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2815903Swosch// 2932216Swosch 3032216Swosch#include <iostream> 3132216Swosch#include <sstream> 3232216Swosch#include <string> 33218525Skeramida#include <utility> 34218525Skeramida#include <vector> 3515903Swosch 3615903Swosch#include <atf-c++.hpp> 3715903Swosch 3815903Swosch#include "parser.hpp" 39119057Sobrien#include "reader.hpp" 4015903Swosch#include "test_helpers.hpp" 4115903Swosch#include "text.hpp" 4215903Swosch 4315903Swoschnamespace impl = tools::atf_report; 4415903Swosch 4515903Swoschclass tps_reader : protected impl::atf_tps_reader { 4615903Swosch void 4765501Sobrien got_info(const std::string& what, const std::string& val) 4815903Swosch { 49186894Sbz m_calls.push_back("got_info(" + what + ", " + val + ")"); 5015903Swosch } 51186894Sbz 5215903Swosch void 5353033Sphantom got_ntps(size_t ntps) 5415903Swosch { 5515903Swosch m_calls.push_back("got_ntps(" + tools::text::to_string(ntps) + ")"); 5615903Swosch } 5715903Swosch 5815903Swosch void 5939161Sobrien got_tp_start(const std::string& tpname, size_t ntcs) 6015903Swosch { 6139161Sobrien m_calls.push_back("got_tp_start(" + tpname + ", " + 6215903Swosch tools::text::to_string(ntcs) + ")"); 6315903Swosch } 6415903Swosch 6515903Swosch void 66223596Sse got_tp_end(struct timeval* tv __attribute__((__unused__)), 67223596Sse const std::string& reason) 68223596Sse { 69223596Sse m_calls.push_back("got_tp_end(" + reason + ")"); 70223596Sse } 71223596Sse 72223596Sse void 73223596Sse got_tc_start(const std::string& tcname) 74223596Sse { 7515903Swosch m_calls.push_back("got_tc_start(" + tcname + ")"); 7615903Swosch } 7715903Swosch 7815903Swosch void 7915903Swosch got_tc_end(const std::string& state, 8015903Swosch struct timeval* tv __attribute__((__unused__)), 8115903Swosch const std::string& reason) 8215903Swosch { 8315903Swosch const std::string r = state + (reason.empty() ? "" : ", " + reason); 8415903Swosch m_calls.push_back("got_tc_end(" + r + ")"); 8515903Swosch } 8615903Swosch 8715903Swosch void 8815903Swosch got_tc_stdout_line(const std::string& line) 8915903Swosch { 9015903Swosch m_calls.push_back("got_tc_stdout_line(" + line + ")"); 9115903Swosch } 9215903Swosch 9315903Swosch void 9415903Swosch got_tc_stderr_line(const std::string& line) 9515903Swosch { 9615903Swosch m_calls.push_back("got_tc_stderr_line(" + line + ")"); 9715903Swosch } 9815903Swosch 9915903Swosch void 10015903Swosch got_eof(void) 10115903Swosch { 10215903Swosch m_calls.push_back("got_eof()"); 10315903Swosch } 10415903Swosch 10590627Sphantompublic: 10615903Swosch tps_reader(std::istream& is) : 10790626Sphantom impl::atf_tps_reader(is) 10815903Swosch { 10990626Sphantom } 11015903Swosch 11161462Sghelmer void 11215903Swosch read(void) 11332216Swosch { 11415903Swosch atf_tps_reader::read(); 11594982Sru } 11694982Sru 11794982Sru std::vector< std::string > m_calls; 118164411Sru}; 119156813Sru 120156836SruATF_TEST_CASE_WITHOUT_HEAD(tps_1); 121156836SruATF_TEST_CASE_BODY(tps_1) 122156836Sru{ 123164411Sru const char* input = 124156813Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 12514968Swosch "\n" 12639161Sobrien "tps-count: 0\n" 12739161Sobrien ; 12814573Swosch 12914968Swosch const char* exp_calls[] = { 13014573Swosch "got_ntps(0)", 131111853Sru "got_eof()", 132111853Sru NULL 133111853Sru }; 13465501Sobrien 135111853Sru const char* exp_errors[] = { 13648204Sjmg NULL 13748204Sjmg }; 13848204Sjmg 13948204Sjmg do_parser_test< tps_reader >(input, exp_calls, exp_errors); 14014573Swosch} 14132226Ssteve 14232226SsteveATF_TEST_CASE_WITHOUT_HEAD(tps_2); 143218525SkeramidaATF_TEST_CASE_BODY(tps_2) 14414573Swosch{ 14514573Swosch const char* input = 14614968Swosch "Content-Type: application/X-atf-tps; version=\"3\"\n" 14714968Swosch "\n" 14814968Swosch "tps-count: 2\n" 14914573Swosch "tp-start: 123.456, first-prog, 0\n" 15014968Swosch "tp-end: 123.567, first-prog\n" 15114968Swosch "tp-start: 123.678, second-prog, 0\n" 15214968Swosch "tp-end: 123.789, second-prog, This program failed\n" 15339161Sobrien ; 15439161Sobrien 15514968Swosch const char* exp_calls[] = { 15614968Swosch "got_ntps(2)", 157223596Sse "got_tp_start(first-prog, 0)", 158223596Sse "got_tp_end()", 159223596Sse "got_tp_start(second-prog, 0)", 160223596Sse "got_tp_end(This program failed)", 161223596Sse "got_eof()", 16214968Swosch NULL 16314968Swosch }; 16414968Swosch 16514968Swosch const char* exp_errors[] = { 16614968Swosch NULL 16714968Swosch }; 16814968Swosch 16914968Swosch do_parser_test< tps_reader >(input, exp_calls, exp_errors); 17014968Swosch} 17114968Swosch 17214968SwoschATF_TEST_CASE_WITHOUT_HEAD(tps_3); 17314968SwoschATF_TEST_CASE_BODY(tps_3) 17414968Swosch{ 17514968Swosch const char* input = 17614968Swosch "Content-Type: application/X-atf-tps; version=\"3\"\n" 17714968Swosch "\n" 17890626Sphantom "tps-count: 2\n" 17990626Sphantom "tp-start: 123.123, first-prog, 3\n" 18061462Sghelmer "tc-start: 123.234, first-test\n" 18114968Swosch "tc-end: 123.345, first-test, passed\n" 18232216Swosch "tc-start: 123.456, second-test\n" 18332216Swosch "tc-end: 123.567, second-test, skipped, Testing skipped reason\n" 184245752Sbrooks "tc-start: 123.678, third.test\n" 185245752Sbrooks "tc-end: 123.789, third.test, failed, Testing failed reason\n" 186245752Sbrooks "tp-end: 123.890, first-prog\n" 187245752Sbrooks "tp-start: 124.901, second-prog, 3\n" 188245752Sbrooks "tc-start: 124.1012, first-test\n" 189245752Sbrooks "tc-so:first stdout line for 1st test\n" 190245752Sbrooks "tc-se:first stderr line for 1st test\n" 191245752Sbrooks "tc-so:second stdout line for 1st test\n" 192245752Sbrooks "tc-se:second stderr line for 1st test\n" 19314968Swosch "tc-end: 124.1123, first-test, passed\n" 194125494Sru "tc-start: 124.1234, second-test\n" 195125494Sru "tc-so:first stdout line for 2nd test\n" 196125494Sru "tc-se:first stderr line for 2nd test\n" 197125494Sru "tc-so:second stdout line for 2nd test\n" 19834678Sbde "tc-se:second stderr line for 2nd test\n" 19923546Swosch "tc-end: 124.1345, second-test, skipped, Testing skipped reason\n" 20094982Sru "tc-start: 124.1456, third.test\n" 201164411Sru "tc-so:first stdout line for 3rd test\n" 202156813Sru "tc-se:first stderr line for 3rd test\n" 203156813Sru "tc-so:second stdout line for 3rd test\n" 204156813Sru "tc-se:second stderr line for 3rd test\n" 205156813Sru "tc-end: 124.1567, third.test, failed, Testing failed reason\n" 206156813Sru "tp-end: 124.1678, second-prog, This program failed\n" 207156813Sru ; 208156813Sru 209156813Sru const char* exp_calls[] = { 210156813Sru "got_ntps(2)", 211156813Sru "got_tp_start(first-prog, 3)", 212156813Sru "got_tc_start(first-test)", 213156813Sru "got_tc_end(passed)", 214156813Sru "got_tc_start(second-test)", 215228158Sfjoe "got_tc_end(skipped, Testing skipped reason)", 216172832Sru "got_tc_start(third.test)", 217156869Sru "got_tc_end(failed, Testing failed reason)", 218156869Sru "got_tp_end()", 219156813Sru "got_tp_start(second-prog, 3)", 220228120Sfjoe "got_tc_start(first-test)", 221228120Sfjoe "got_tc_stdout_line(first stdout line for 1st test)", 222228120Sfjoe "got_tc_stderr_line(first stderr line for 1st test)", 223156813Sru "got_tc_stdout_line(second stdout line for 1st test)", 224156813Sru "got_tc_stderr_line(second stderr line for 1st test)", 225156813Sru "got_tc_end(passed)", 226156813Sru "got_tc_start(second-test)", 227156813Sru "got_tc_stdout_line(first stdout line for 2nd test)", 228156813Sru "got_tc_stderr_line(first stderr line for 2nd test)", 229156813Sru "got_tc_stdout_line(second stdout line for 2nd test)", 230156813Sru "got_tc_stderr_line(second stderr line for 2nd test)", 231156813Sru "got_tc_end(skipped, Testing skipped reason)", 232156813Sru "got_tc_start(third.test)", 233156813Sru "got_tc_stdout_line(first stdout line for 3rd test)", 234156813Sru "got_tc_stderr_line(first stderr line for 3rd test)", 235156813Sru "got_tc_stdout_line(second stdout line for 3rd test)", 236156813Sru "got_tc_stderr_line(second stderr line for 3rd test)", 237220359Simp "got_tc_end(failed, Testing failed reason)", 238183242Ssam "got_tp_end(This program failed)", 239156813Sru "got_eof()", 240183242Ssam NULL 241183242Ssam }; 242162210Simp 243183242Ssam const char* exp_errors[] = { 244241823Smarcel NULL 245156813Sru }; 246156813Sru 247156813Sru do_parser_test< tps_reader >(input, exp_calls, exp_errors); 248156813Sru} 249156813Sru 250156813SruATF_TEST_CASE_WITHOUT_HEAD(tps_4); 251156813SruATF_TEST_CASE_BODY(tps_4) 252156813Sru{ 253156813Sru const char* input = 254156813Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 255222090Simp "\n" 256156813Sru "info: a, foo\n" 257156813Sru "info: b, bar\n" 258179815Sdougb "info: c, baz\n" 259183242Ssam "tps-count: 2\n" 260166255Sdelphij "tp-start: 234.1, first-prog, 3\n" 261156813Sru "tc-start: 234.12, first-test\n" 262229319Srwatson "tc-end: 234.23, first-test, passed\n" 263163861Sjb "tc-start: 234.34, second-test\n" 264156813Sru "tc-end: 234.45, second-test, skipped, Testing skipped reason\n" 265156813Sru "tc-start: 234.56, third-test\n" 266183242Ssam "tc-end: 234.67, third-test, failed, Testing failed reason\n" 267156813Sru "tp-end: 234.78, first-prog\n" 268156813Sru "tp-start: 234.89, second-prog, 3\n" 269156813Sru "tc-start: 234.90, first-test\n" 270156813Sru "tc-so:first stdout line for 1st test\n" 271235654Smarcel "tc-se:first stderr line for 1st test\n" 272156813Sru "tc-so:second stdout line for 1st test\n" 273183242Ssam "tc-se:second stderr line for 1st test\n" 274156813Sru "tc-end: 234.101, first-test, passed\n" 275156813Sru "tc-start: 234.112, second-test\n" 276183242Ssam "tc-so:first stdout line for 2nd test\n" 277156813Sru "tc-se:first stderr line for 2nd test\n" 278222090Simp "tc-so:second stdout line for 2nd test\n" 279156813Sru "tc-se:second stderr line for 2nd test\n" 280156813Sru "tc-end: 234.123, second-test, skipped, Testing skipped reason\n" 281156813Sru "tc-start: 234.134, third-test\n" 282156813Sru "tc-so:first stdout line for 3rd test\n" 283220359Simp "tc-se:first stderr line for 3rd test\n" 284156813Sru "tc-so:second stdout line for 3rd test\n" 285156813Sru "tc-se:second stderr line for 3rd test\n" 286221266Sbz "tc-end: 234.145, third-test, failed, Testing failed reason\n" 287156813Sru "tp-end: 234.156, second-prog, This program failed\n" 288156813Sru "info: d, foo\n" 289172832Sru "info: e, bar\n" 290156813Sru "info: f, baz\n" 291183242Ssam ; 292156813Sru 293183242Ssam const char* exp_calls[] = { 294240404Sobrien "got_info(a, foo)", 295156813Sru "got_info(b, bar)", 296222185Simp "got_info(c, baz)", 297170644Ssepotvin "got_ntps(2)", 298246827Sdes "got_tp_start(first-prog, 3)", 299183242Ssam "got_tc_start(first-test)", 300157115Sru "got_tc_end(passed)", 301156813Sru "got_tc_start(second-test)", 302156813Sru "got_tc_end(skipped, Testing skipped reason)", 303156813Sru "got_tc_start(third-test)", 304183242Ssam "got_tc_end(failed, Testing failed reason)", 305156813Sru "got_tp_end()", 306235655Smarcel "got_tp_start(second-prog, 3)", 307183242Ssam "got_tc_start(first-test)", 308156813Sru "got_tc_stdout_line(first stdout line for 1st test)", 309183242Ssam "got_tc_stderr_line(first stderr line for 1st test)", 310156813Sru "got_tc_stdout_line(second stdout line for 1st test)", 311183242Ssam "got_tc_stderr_line(second stderr line for 1st test)", 312156813Sru "got_tc_end(passed)", 313183242Ssam "got_tc_start(second-test)", 314156813Sru "got_tc_stdout_line(first stdout line for 2nd test)", 315156813Sru "got_tc_stderr_line(first stderr line for 2nd test)", 316156813Sru "got_tc_stdout_line(second stdout line for 2nd test)", 317158115Sume "got_tc_stderr_line(second stderr line for 2nd test)", 318183242Ssam "got_tc_end(skipped, Testing skipped reason)", 319156813Sru "got_tc_start(third-test)", 320156813Sru "got_tc_stdout_line(first stdout line for 3rd test)", 321156813Sru "got_tc_stderr_line(first stderr line for 3rd test)", 322245606Seadler "got_tc_stdout_line(second stdout line for 3rd test)", 323156813Sru "got_tc_stderr_line(second stderr line for 3rd test)", 324238010Sglebius "got_tc_end(failed, Testing failed reason)", 325183242Ssam "got_tp_end(This program failed)", 326183242Ssam "got_info(d, foo)", 327183242Ssam "got_info(e, bar)", 328183242Ssam "got_info(f, baz)", 329228196Sfjoe "got_eof()", 330183242Ssam NULL 331156813Sru }; 332156813Sru 333156813Sru const char* exp_errors[] = { 334183242Ssam NULL 335156813Sru }; 336156813Sru 337156813Sru do_parser_test< tps_reader >(input, exp_calls, exp_errors); 338244527Semaste} 339244527Semaste 340244527SemasteATF_TEST_CASE_WITHOUT_HEAD(tps_5); 341169724SkanATF_TEST_CASE_BODY(tps_5) 342169524Sdeischen{ 343156813Sru const char* input = 344244527Semaste "Content-Type: application/X-atf-tps; version=\"3\"\n" 345156813Sru "\n" 346183242Ssam "tps-count: 1\n" 347183242Ssam "tp-start: 345.123, the-prog, 1\n" 348156813Sru "tc-start: 345.134, the-test\n" 349156813Sru "tc-so:--- a 2007-11-04 14:00:41.000000000 +0100\n" 350223209Sed "tc-so:+++ b 2007-11-04 14:00:48.000000000 +0100\n" 351183242Ssam "tc-so:@@ -1,7 +1,7 @@\n" 352168409Spjd "tc-so: This test is meant to simulate a diff.\n" 353175617Sru "tc-so: Blank space at beginning of context lines must be preserved.\n" 354175617Sru "tc-so: \n" 355220359Simp "tc-so:-First original line.\n" 356220359Simp "tc-so:-Second original line.\n" 357245539Sandrew "tc-so:+First modified line.\n" 358246074Sgabor "tc-so:+Second modified line.\n" 359220359Simp "tc-so: \n" 360220359Simp "tc-so: EOF\n" 361220359Simp "tc-end: 345.145, the-test, passed\n" 362220359Simp "tp-end: 345.156, the-prog\n" 363220359Simp ; 364244527Semaste 365238438Sdteske // NO_CHECK_STYLE_BEGIN 366244527Semaste const char* exp_calls[] = { 367231057Sdim "got_ntps(1)", 368228158Sfjoe "got_tp_start(the-prog, 1)", 369245803Stheraven "got_tc_start(the-test)", 370220359Simp "got_tc_stdout_line(--- a 2007-11-04 14:00:41.000000000 +0100)", 371220359Simp "got_tc_stdout_line(+++ b 2007-11-04 14:00:48.000000000 +0100)", 372220359Simp "got_tc_stdout_line(@@ -1,7 +1,7 @@)", 373237612Sobrien "got_tc_stdout_line( This test is meant to simulate a diff.)", 374246827Sdes "got_tc_stdout_line( Blank space at beginning of context lines must be preserved.)", 375245241Sbrooks "got_tc_stdout_line( )", 376235537Sgber "got_tc_stdout_line(-First original line.)", 377234782Skib "got_tc_stdout_line(-Second original line.)", 378245527Sbz "got_tc_stdout_line(+First modified line.)", 379234782Skib "got_tc_stdout_line(+Second modified line.)", 380220359Simp "got_tc_stdout_line( )", 381220359Simp "got_tc_stdout_line( EOF)", 382220359Simp "got_tc_end(passed)", 383220359Simp "got_tp_end()", 384220359Simp "got_eof()", 385220359Simp NULL 386221726Sru }; 387220359Simp // NO_CHECK_STYLE_END 388220359Simp 389220359Simp const char* exp_errors[] = { 390220359Simp NULL 391220359Simp }; 392220359Simp 393220359Simp do_parser_test< tps_reader >(input, exp_calls, exp_errors); 394246354Sandrew} 395235133Sdim 396246259SdimATF_TEST_CASE_WITHOUT_HEAD(tps_6); 397246354SandrewATF_TEST_CASE_BODY(tps_6) 398246354Sandrew{ 399246354Sandrew const char* input = 400246354Sandrew "Content-Type: application/X-atf-tps; version=\"3\"\n" 401220359Simp "\n" 402246259Sdim "tps-count: 1\n" 403220359Simp "tp-start: 321.1, the-prog, 8\n" 404242624Sbrooks "tc-start: 321.12, one\n" 405242624Sbrooks "tc-end: 321.23, one, expected_death, The reason\n" 406242624Sbrooks "tc-start: 321.34, two\n" 407242624Sbrooks "tc-end: 321.45, two, expected_exit, This would be an exit\n" 408242624Sbrooks "tc-start: 321.56, three\n" 409242624Sbrooks "tc-end: 321.67, three, expected_failure, And this a failure\n" 410227775Snwhitehorn "tc-start: 321.78, four\n" 411227775Snwhitehorn "tc-end: 321.89, four, expected_signal, And this a signal\n" 412220359Simp "tc-start: 321.90, five\n" 413220359Simp "tc-end: 321.101, five, failed, Another reason\n" 414220359Simp "tc-start: 321.112, six\n" 415220359Simp "tc-end: 321.123, six, passed\n" 416220359Simp "tc-start: 321.134, seven\n" 417220359Simp "tc-end: 321.145, seven, skipped, Skipping it\n" 418220359Simp "tc-start: 321.156, eight\n" 419220359Simp "tc-end: 321.167, eight, expected_timeout, Some hang reason\n" 420220359Simp "tp-end: 321.178, the-prog\n" 421220359Simp ; 422156813Sru 423156813Sru // NO_CHECK_STYLE_BEGIN 424156813Sru const char* exp_calls[] = { 425156813Sru "got_ntps(1)", 426156813Sru "got_tp_start(the-prog, 8)", 427156813Sru "got_tc_start(one)", 428156813Sru "got_tc_end(expected_death, The reason)", 429156813Sru "got_tc_start(two)", 430156813Sru "got_tc_end(expected_exit, This would be an exit)", 431156813Sru "got_tc_start(three)", 432156813Sru "got_tc_end(expected_failure, And this a failure)", 433156813Sru "got_tc_start(four)", 434220359Simp "got_tc_end(expected_signal, And this a signal)", 435156813Sru "got_tc_start(five)", 436156813Sru "got_tc_end(failed, Another reason)", 437156813Sru "got_tc_start(six)", 438156813Sru "got_tc_end(passed)", 439220359Simp "got_tc_start(seven)", 440156813Sru "got_tc_end(skipped, Skipping it)", 441156813Sru "got_tc_start(eight)", 442156813Sru "got_tc_end(expected_timeout, Some hang reason)", 443156813Sru "got_tp_end()", 444156813Sru "got_eof()", 445156813Sru NULL 446156813Sru }; 447156813Sru // NO_CHECK_STYLE_END 448156813Sru 449156813Sru const char* exp_errors[] = { 450156813Sru NULL 451156813Sru }; 452220359Simp 453156813Sru do_parser_test< tps_reader >(input, exp_calls, exp_errors); 454156813Sru} 455156813Sru 456172571Sru 457156813SruATF_TEST_CASE_WITHOUT_HEAD(tps_50); 458172571SruATF_TEST_CASE_BODY(tps_50) 459172571Sru{ 460172571Sru const char* input = 461172571Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 462177714Sru "\n" 463172571Sru "foo\n" 464172571Sru ; 465172571Sru 466156813Sru const char* exp_calls[] = { 467156813Sru NULL 468156813Sru }; 469156813Sru 470156813Sru const char* exp_errors[] = { 471156813Sru "3: Unexpected token `foo'; expected tps-count or info field", 472156813Sru NULL 473156813Sru }; 474156813Sru 475156813Sru do_parser_test< tps_reader >(input, exp_calls, exp_errors); 476246827Sdes} 477246827Sdes 478246827SdesATF_TEST_CASE_WITHOUT_HEAD(tps_51); 479246827SdesATF_TEST_CASE_BODY(tps_51) 480246833Sdes{ 481246827Sdes const char* input = 482246827Sdes "Content-Type: application/X-atf-tps; version=\"3\"\n" 483246827Sdes "\n" 484157378Sphk "tps-count\n" 485157378Sphk ; 486157378Sphk 487157378Sphk const char* exp_calls[] = { 488230972Srmh NULL 489230972Srmh }; 490230972Srmh 491230972Srmh const char* exp_errors[] = { 492230972Srmh "3: Unexpected token `<<NEWLINE>>'; expected `:'", 493168409Spjd NULL 494168409Spjd }; 495228158Sfjoe 496168409Spjd do_parser_test< tps_reader >(input, exp_calls, exp_errors); 497168409Spjd} 498156813Sru 499156813SruATF_TEST_CASE_WITHOUT_HEAD(tps_52); 500156813SruATF_TEST_CASE_BODY(tps_52) 501156813Sru{ 502156813Sru const char* input = 503156813Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 504220401Suqs "\n" 505220401Suqs "tps-count:\n" 506220401Suqs ; 507220401Suqs 508220401Suqs const char* exp_calls[] = { 509183242Ssam NULL 510183242Ssam }; 511183242Ssam 512183242Ssam const char* exp_errors[] = { 513183242Ssam "3: Unexpected token `<<NEWLINE>>'; expected number of test programs", 514202440Santoine NULL 515202440Santoine }; 516202440Santoine 517202440Santoine do_parser_test< tps_reader >(input, exp_calls, exp_errors); 518202440Santoine} 519156813Sru 520156813SruATF_TEST_CASE_WITHOUT_HEAD(tps_53); 521156813SruATF_TEST_CASE_BODY(tps_53) 522156813Sru{ 523156813Sru const char* input = 524156813Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 525156813Sru "\n" 526156813Sru "tps-count: 1\n" 527156813Sru "foo\n" 528183242Ssam ; 529183242Ssam 530183242Ssam const char* exp_calls[] = { 531183242Ssam "got_ntps(1)", 532156813Sru NULL 533222090Simp }; 534208964Srdivacky 535222090Simp const char* exp_errors[] = { 536156813Sru "4: Unexpected token `foo'; expected start of test program", 537156813Sru NULL 538156813Sru }; 539232322Sdim 540246131Sdim do_parser_test< tps_reader >(input, exp_calls, exp_errors); 541246259Sdim} 542232322Sdim 543232322SdimATF_TEST_CASE_WITHOUT_HEAD(tps_54); 544232322SdimATF_TEST_CASE_BODY(tps_54) 545156813Sru{ 546156813Sru const char* input = 547156813Sru "Content-Type: application/X-atf-tps; version=\"3\"\n" 548156813Sru "\n" 549156813Sru "tps-count: 1\n" 550156813Sru "foo\n" 551156813Sru "tp-start\n" 552156813Sru "tp-start:\n" 553156813Sru "tp-start: 123\n" 554166255Sdelphij "tp-start: 123.\n" 555156813Sru "tp-start: 123.456\n" 556221266Sbz "tp-start: 123.456,\n" 557156813Sru "tp-start: 123.456, foo\n" 558156813Sru "tp-start: 123.456, foo,\n" 559156813Sru "tp-start: 123.456, foo, 0\n" 560170644Ssepotvin "bar\n" 561183242Ssam "tp-start: 456.789, foo, 0\n" 562183242Ssam "tp-end\n" 563183242Ssam "tp-start: 777.777, foo, 0\n" 564156813Sru "tp-end:\n" 565156813Sru "tp-start: 777.777, foo, 0\n" 566156813Sru "tp-end: 777\n" 567156813Sru "tp-start: 777.777, foo, 0\n" 568156813Sru "tp-end: 777.\n" 569156813Sru "tp-start: 777.777, foo, 0\n" 570156813Sru "tp-end: 777.888\n" 571156813Sru "tp-start: 777.777, foo, 0\n" 572156813Sru "tp-end: 777.888, \n" 573156813Sru "tp-start: 777.777, foo, 0\n" 574156813Sru "tp-end: 777.888, bar\n" 575156813Sru "tp-start: 777.777, foo, 0\n" 576174548Sru "tp-end: 777.888, foo,\n" 577174548Sru ; 578174548Sru 579174548Sru const char* exp_calls[] = { 580174548Sru "got_ntps(1)", 581208320Sjkim NULL 582208320Sjkim }; 583174548Sru 584174548Sru const char* exp_errors[] = { 585174548Sru "4: Unexpected token `foo'; expected start of test program", 586174548Sru "5: Unexpected token `<<NEWLINE>>'; expected `:'", 587174548Sru "6: Unexpected token `<<NEWLINE>>'; expected timestamp", 588174548Sru "7: Malformed timestamp value 123", 589174548Sru "8: Malformed timestamp value 123.", 590174548Sru "9: Unexpected token `<<NEWLINE>>'; expected `,'", 591174548Sru "10: Unexpected token `<<NEWLINE>>'; expected test program name", 592174548Sru "11: Unexpected token `<<NEWLINE>>'; expected `,'", 593174548Sru "12: Unexpected token `<<NEWLINE>>'; expected number of test programs", 594174548Sru "14: Unexpected token `bar'; expected end of test program", 595174548Sru "16: Unexpected token `<<NEWLINE>>'; expected `:'", 596174548Sru "18: Unexpected token `<<NEWLINE>>'; expected timestamp", 597174548Sru "20: Malformed timestamp value 777", 598240966Sbrooks "22: Malformed timestamp value 777.", 599240966Sbrooks "24: Unexpected token `<<NEWLINE>>'; expected `,'", 600240966Sbrooks 601240966Sbrooks "26: Unexpected token `<<NEWLINE>>'; expected test program name", 602240966Sbrooks "28: Test program name used in terminator does not match opening", 603240966Sbrooks "30: Empty reason for failed test program", 604240966Sbrooks NULL 605240966Sbrooks }; 606240966Sbrooks 607240966Sbrooks do_parser_test< tps_reader >(input, exp_calls, exp_errors); 608240966Sbrooks} 609240966Sbrooks 610240966SbrooksATF_TEST_CASE_WITHOUT_HEAD(tps_55); 611240966SbrooksATF_TEST_CASE_BODY(tps_55) 612240966Sbrooks{ 613240966Sbrooks const char* input = 614240966Sbrooks "Content-Type: application/X-atf-tps; version=\"3\"\n" 615240966Sbrooks "\n" 616240966Sbrooks "tps-count: 1\n" 617240966Sbrooks "tp-start: 100.200, foo, 1\n" 618240966Sbrooks "foo\n" 619240966Sbrooks "tc-start\n" 620240966Sbrooks "tc-start:\n" 621240966Sbrooks "tc-start: 111\n" 622240966Sbrooks "tc-start: 111.\n" 623240966Sbrooks "tc-start: 111.222\n" 624240966Sbrooks "tc-start: 111.222,\n" 625228158Sfjoe "tc-start: 111.222, foo\n" 626228158Sfjoe "bar\n" 627243393Ssjg "tc-start: 111.333, foo\n" 628228158Sfjoe "tc-end\n" 629228158Sfjoe "tc-start: 111.444, foo\n" 630228158Sfjoe "tc-end:\n" 631228158Sfjoe "tc-start: 111.444, foo\n" 632228158Sfjoe "tc-end: 111\n" 633237612Sobrien "tc-start: 111.444, foo\n" 634243392Ssjg "tc-end: 111.\n" 635237612Sobrien "tc-start: 111.444, foo\n" 636243392Ssjg "tc-end: 111.555\n" 637243392Ssjg "tc-start: 111.444, foo\n" 638243392Ssjg "tc-end: 111.555, \n" 639237612Sobrien "tc-start: 111.444, foo\n" 640237612Sobrien "tc-end: 111.555, bar\n" 641243392Ssjg "tc-start: 111.444, foo\n" 642237612Sobrien "tc-end: 111.555, foo\n" 643237612Sobrien "tc-start: 111.444, foo\n" 644237612Sobrien "tc-end: 111.555, foo,\n" 645237612Sobrien "tp-end: 111.666, foo\n" 646237612Sobrien ; 647164411Sru 648156813Sru const char* exp_calls[] = { 649144893Sharti "got_ntps(1)", 650 "got_tp_start(foo, 1)", 651 NULL 652 }; 653 654 // NO_CHECK_STYLE_BEGIN 655 const char* exp_errors[] = { 656 "5: Unexpected token `foo'; expected start of test case", 657 "6: Unexpected token `<<NEWLINE>>'; expected `:'", 658 "7: Unexpected token `<<NEWLINE>>'; expected timestamp", 659 "8: Malformed timestamp value 111", 660 "9: Malformed timestamp value 111.", 661 "10: Unexpected token `<<NEWLINE>>'; expected `,'", 662 "11: Unexpected token `<<NEWLINE>>'; expected test case name", 663 "13: Unexpected token `bar'; expected end of test case or test case's stdout/stderr line", 664 "15: Unexpected token `<<NEWLINE>>'; expected `:'", 665 "17: Unexpected token `<<NEWLINE>>'; expected timestamp", 666 "19: Malformed timestamp value 111", 667 "21: Malformed timestamp value 111.", 668 "23: Unexpected token `<<NEWLINE>>'; expected `,'", 669 "25: Unexpected token `<<NEWLINE>>'; expected test case name", 670 "27: Test case name used in terminator does not match opening", 671 "29: Unexpected token `<<NEWLINE>>'; expected `,'", 672 "31: Unexpected token `<<NEWLINE>>'; expected expected_{death,exit,failure,signal,timeout}, failed, passed or skipped", 673 "32: Unexpected token `tp-end'; expected start of test case", 674 NULL 675 }; 676 // NO_CHECK_STYLE_END 677 678 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 679} 680 681ATF_TEST_CASE_WITHOUT_HEAD(tps_56); 682ATF_TEST_CASE_BODY(tps_56) 683{ 684 const char* input = 685 "Content-Type: application/X-atf-tps; version=\"3\"\n" 686 "\n" 687 "tps-count: 1\n" 688 "tp-start: 111.222, foo, 1\n" 689 "tc-start: 111.333, foo\n" 690 "tc-end: 111.444, foo, passe\n" 691 "tc-start: 111.333, foo\n" 692 "tc-end: 111.444, foo, passed,\n" 693 "tc-start: 111.555, bar\n" 694 "tc-end: 111.666, bar, failed\n" 695 "tc-start: 111.555, bar\n" 696 "tc-end: 111.666, bar, failed,\n" 697 "tc-start: 111.555, baz\n" 698 "tc-end: 111.666, baz, skipped\n" 699 "tc-start: 111.555, baz\n" 700 "tc-end: 111.666, baz, skipped,\n" 701 "tp-end: 111.777, foo\n" 702 ; 703 704 const char* exp_calls[] = { 705 "got_ntps(1)", 706 "got_tp_start(foo, 1)", 707 "got_tc_start(foo)", 708 NULL 709 }; 710 711 // NO_CHECK_STYLE_BEGIN 712 const char* exp_errors[] = { 713 "6: Unexpected token `passe'; expected expected_{death,exit,failure,signal,timeout}, failed, passed or skipped", 714 "8: Unexpected token `,'; expected new line", 715 "10: Unexpected token `<<NEWLINE>>'; expected `,'", 716 "12: Empty reason for failed test case result", 717 "14: Unexpected token `<<NEWLINE>>'; expected `,'", 718 "16: Empty reason for skipped test case result", 719 "17: Unexpected token `tp-end'; expected start of test case", 720 NULL 721 }; 722 // NO_CHECK_STYLE_END 723 724 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 725} 726 727ATF_TEST_CASE_WITHOUT_HEAD(tps_57); 728ATF_TEST_CASE_BODY(tps_57) 729{ 730 const char* input = 731 "Content-Type: application/X-atf-tps; version=\"3\"\n" 732 "\n" 733 "tps-count: 2\n" 734 "tp-start: 111.222, foo, 0\n" 735 "tp-end: 111.333, foo\n" 736 ; 737 738 const char* exp_calls[] = { 739 "got_ntps(2)", 740 "got_tp_start(foo, 0)", 741 "got_tp_end()", 742 NULL 743 }; 744 745 const char* exp_errors[] = { 746 "6: Unexpected token `<<EOF>>'; expected start of test program", 747 NULL 748 }; 749 750 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 751} 752 753ATF_TEST_CASE_WITHOUT_HEAD(tps_58); 754ATF_TEST_CASE_BODY(tps_58) 755{ 756 const char* input = 757 "Content-Type: application/X-atf-tps; version=\"3\"\n" 758 "\n" 759 "tps-count: 1\n" 760 "tp-start: 111.222, foo, 0\n" 761 "tp-end: 111.333, foo\n" 762 "tp-start: 111.444, bar, 0\n" 763 "tp-end: 111.555, bar\n" 764 ; 765 766 const char* exp_calls[] = { 767 "got_ntps(1)", 768 "got_tp_start(foo, 0)", 769 "got_tp_end()", 770 NULL 771 }; 772 773 const char* exp_errors[] = { 774 "6: Unexpected token `tp-start'; expected end of stream or info field", 775 NULL 776 }; 777 778 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 779} 780 781ATF_TEST_CASE_WITHOUT_HEAD(tps_59); 782ATF_TEST_CASE_BODY(tps_59) 783{ 784 const char* input = 785 "Content-Type: application/X-atf-tps; version=\"3\"\n" 786 "\n" 787 "info\n" 788 ; 789 790 const char* exp_calls[] = { 791 NULL 792 }; 793 794 const char* exp_errors[] = { 795 "3: Unexpected token `<<NEWLINE>>'; expected `:'", 796 NULL 797 }; 798 799 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 800} 801 802ATF_TEST_CASE_WITHOUT_HEAD(tps_60); 803ATF_TEST_CASE_BODY(tps_60) 804{ 805 const char* input = 806 "Content-Type: application/X-atf-tps; version=\"3\"\n" 807 "\n" 808 "info:\n" 809 ; 810 811 const char* exp_calls[] = { 812 NULL 813 }; 814 815 const char* exp_errors[] = { 816 "3: Unexpected token `<<NEWLINE>>'; expected info property name", 817 NULL 818 }; 819 820 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 821} 822 823ATF_TEST_CASE_WITHOUT_HEAD(tps_61); 824ATF_TEST_CASE_BODY(tps_61) 825{ 826 const char* input = 827 "Content-Type: application/X-atf-tps; version=\"3\"\n" 828 "\n" 829 "info: a\n" 830 ; 831 832 const char* exp_calls[] = { 833 NULL 834 }; 835 836 const char* exp_errors[] = { 837 "3: Unexpected token `<<NEWLINE>>'; expected `,'", 838 NULL 839 }; 840 841 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 842} 843 844ATF_TEST_CASE_WITHOUT_HEAD(tps_62); 845ATF_TEST_CASE_BODY(tps_62) 846{ 847 const char* input = 848 "Content-Type: application/X-atf-tps; version=\"3\"\n" 849 "\n" 850 "info: a,\n" 851 ; 852 853 const char* exp_calls[] = { 854 "got_info(a, )", 855 NULL 856 }; 857 858 const char* exp_errors[] = { 859 "4: Unexpected token `<<EOF>>'; expected tps-count or info field", 860 NULL 861 }; 862 863 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 864} 865 866ATF_TEST_CASE_WITHOUT_HEAD(tps_63); 867ATF_TEST_CASE_BODY(tps_63) 868{ 869 const char* input = 870 "Content-Type: application/X-atf-tps; version=\"3\"\n" 871 "\n" 872 "info: a, b\n" 873 ; 874 875 const char* exp_calls[] = { 876 "got_info(a, b)", 877 NULL 878 }; 879 880 const char* exp_errors[] = { 881 "4: Unexpected token `<<EOF>>'; expected tps-count or info field", 882 NULL 883 }; 884 885 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 886} 887 888ATF_TEST_CASE_WITHOUT_HEAD(tps_64); 889ATF_TEST_CASE_BODY(tps_64) 890{ 891 const char* input = 892 "Content-Type: application/X-atf-tps; version=\"3\"\n" 893 "\n" 894 "info: a, b\n" 895 "info: a.b.c.def, g\n" 896 "tps-count\n" 897 ; 898 899 const char* exp_calls[] = { 900 "got_info(a, b)", 901 "got_info(a.b.c.def, g)", 902 NULL 903 }; 904 905 const char* exp_errors[] = { 906 "5: Unexpected token `<<NEWLINE>>'; expected `:'", 907 NULL 908 }; 909 910 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 911} 912 913ATF_TEST_CASE_WITHOUT_HEAD(tps_65); 914ATF_TEST_CASE_BODY(tps_65) 915{ 916 const char* input = 917 "Content-Type: application/X-atf-tps; version=\"3\"\n" 918 "\n" 919 "info: a, b\n" 920 "tps-count:\n" 921 ; 922 923 const char* exp_calls[] = { 924 "got_info(a, b)", 925 NULL 926 }; 927 928 const char* exp_errors[] = { 929 "4: Unexpected token `<<NEWLINE>>'; expected number of test programs", 930 NULL 931 }; 932 933 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 934} 935 936ATF_TEST_CASE_WITHOUT_HEAD(tps_66); 937ATF_TEST_CASE_BODY(tps_66) 938{ 939 const char* input = 940 "Content-Type: application/X-atf-tps; version=\"3\"\n" 941 "\n" 942 "info: a, b\n" 943 "tps-count: 0\n" 944 "info\n" 945 ; 946 947 const char* exp_calls[] = { 948 "got_info(a, b)", 949 "got_ntps(0)", 950 NULL 951 }; 952 953 const char* exp_errors[] = { 954 "5: Unexpected token `<<NEWLINE>>'; expected `:'", 955 NULL 956 }; 957 958 do_parser_test< tps_reader >(input, exp_calls, exp_errors); 959} 960 961ATF_INIT_TEST_CASES(tcs) 962{ 963 ATF_ADD_TEST_CASE(tcs, tps_1); 964 ATF_ADD_TEST_CASE(tcs, tps_2); 965 ATF_ADD_TEST_CASE(tcs, tps_3); 966 ATF_ADD_TEST_CASE(tcs, tps_4); 967 ATF_ADD_TEST_CASE(tcs, tps_5); 968 ATF_ADD_TEST_CASE(tcs, tps_6); 969 ATF_ADD_TEST_CASE(tcs, tps_50); 970 ATF_ADD_TEST_CASE(tcs, tps_51); 971 ATF_ADD_TEST_CASE(tcs, tps_52); 972 ATF_ADD_TEST_CASE(tcs, tps_53); 973 ATF_ADD_TEST_CASE(tcs, tps_54); 974 ATF_ADD_TEST_CASE(tcs, tps_55); 975 ATF_ADD_TEST_CASE(tcs, tps_56); 976 ATF_ADD_TEST_CASE(tcs, tps_57); 977 ATF_ADD_TEST_CASE(tcs, tps_58); 978 ATF_ADD_TEST_CASE(tcs, tps_59); 979 ATF_ADD_TEST_CASE(tcs, tps_60); 980 ATF_ADD_TEST_CASE(tcs, tps_61); 981 ATF_ADD_TEST_CASE(tcs, tps_62); 982 ATF_ADD_TEST_CASE(tcs, tps_63); 983 ATF_ADD_TEST_CASE(tcs, tps_64); 984 ATF_ADD_TEST_CASE(tcs, tps_65); 985 ATF_ADD_TEST_CASE(tcs, tps_66); 986} 987 988