574
585
g_printerr (":(");
575
586
for (ui = 0; ui < msg->n_nums; ui++)
576
g_printerr ("%s%.16Lg", ui ? ";" : "", msg->nums[ui]);
588
if ((long double) (long) msg->nums[ui] == msg->nums[ui])
589
g_printerr ("%s%ld", ui ? ";" : "", (long) msg->nums[ui]);
591
g_printerr ("%s%.16g", ui ? ";" : "", (double) msg->nums[ui]);
577
593
g_printerr (")");
579
595
g_printerr (":LOG*}\n");
787
else if (strcmp ("-?", argv[i]) == 0 || strcmp ("--help", argv[i]) == 0)
804
else if (strcmp ("-?", argv[i]) == 0 ||
805
strcmp ("-h", argv[i]) == 0 ||
806
strcmp ("--help", argv[i]) == 0)
789
808
printf ("Usage:\n"
790
809
" %s [OPTION...]\n\n"
791
810
"Help Options:\n"
792
" -?, --help Show help options\n"
811
" -h, --help Show help options\n\n"
793
812
"Test Options:\n"
813
" --g-fatal-warnings Make all warnings fatal\n"
794
814
" -l List test cases available in a test executable\n"
795
" -seed=RANDOMSEED Provide a random seed to reproduce test\n"
796
" runs using random numbers\n"
797
" --verbose Run tests verbosely\n"
815
" -m {perf|slow|thorough|quick} Execute tests according to mode\n"
816
" -m {undefined|no-undefined} Execute tests according to mode\n"
817
" -p TESTPATH Only start test cases matching TESTPATH\n"
818
" -s TESTPATH Skip all tests matching TESTPATH\n"
819
" -seed=SEEDSTRING Start tests with random seed SEEDSTRING\n"
820
" --debug-log debug test logging output\n"
798
821
" -q, --quiet Run tests quietly\n"
799
" -p TESTPATH execute all tests matching TESTPATH\n"
800
" -s TESTPATH skip all tests matching TESTPATH\n"
801
" -m {perf|slow|thorough|quick} Execute tests according modes\n"
802
" -m {undefined|no-undefined} Execute tests according modes\n"
803
" --debug-log debug test logging output\n"
804
" -k, --keep-going gtester-specific argument\n"
805
" --GTestLogFD=N gtester-specific argument\n"
806
" --GTestSkipCount=N gtester-specific argument\n",
822
" --verbose Run tests verbosely\n",
837
853
* <term><option>-l</option></term>
838
854
* <listitem><para>
839
* list test cases available in a test executable.
855
* List test cases available in a test executable.
840
856
* </para></listitem>
841
857
* </varlistentry>
843
859
* <term><option>--seed=<replaceable>RANDOMSEED</replaceable></option></term>
844
860
* <listitem><para>
845
* provide a random seed to reproduce test runs using random numbers.
861
* Provide a random seed to reproduce test runs using random numbers.
846
862
* </para></listitem>
847
863
* </varlistentry>
849
865
* <term><option>--verbose</option></term>
850
* <listitem><para>run tests verbosely.</para></listitem>
866
* <listitem><para>Run tests verbosely.</para></listitem>
851
867
* </varlistentry>
853
869
* <term><option>-q</option>, <option>--quiet</option></term>
854
* <listitem><para>run tests quietly.</para></listitem>
870
* <listitem><para>Run tests quietly.</para></listitem>
855
871
* </varlistentry>
857
873
* <term><option>-p <replaceable>TESTPATH</replaceable></option></term>
858
874
* <listitem><para>
859
* execute all tests matching <replaceable>TESTPATH</replaceable>.
875
* Execute all tests matching <replaceable>TESTPATH</replaceable>.
860
876
* </para></listitem>
861
877
* </varlistentry>
863
879
* <term><option>-m {perf|slow|thorough|quick|undefined|no-undefined}</option></term>
864
880
* <listitem><para>
865
* execute tests according to these test modes:
881
* Execute tests according to these test modes:
868
884
* <term>perf</term>
869
885
* <listitem><para>
870
* performance tests, may take long and report results.
886
* Performance tests, may take long and report results.
871
887
* </para></listitem>
872
888
* </varlistentry>
874
890
* <term>slow, thorough</term>
875
891
* <listitem><para>
876
* slow and thorough tests, may take quite long and
892
* Slow and thorough tests, may take quite long and
877
893
* maximize coverage.
878
894
* </para></listitem>
879
895
* </varlistentry>
881
897
* <term>quick</term>
882
898
* <listitem><para>
883
* quick tests, should run really quickly and give good coverage.
899
* Quick tests, should run really quickly and give good coverage.
884
900
* </para></listitem>
885
901
* </varlistentry>
887
903
* <term>undefined</term>
888
904
* <listitem><para>
889
* tests for undefined behaviour, may provoke programming errors
905
* Tests for undefined behaviour, may provoke programming errors
890
906
* under g_test_trap_fork() to check that appropriate assertions
891
907
* or warnings are given
892
908
* </para></listitem>
902
918
* </varlistentry>
904
920
* <term><option>--debug-log</option></term>
905
* <listitem><para>debug test logging output.</para></listitem>
908
* <term><option>-k</option>, <option>--keep-going</option></term>
909
* <listitem><para>gtester-specific argument.</para></listitem>
912
* <term><option>--GTestLogFD <replaceable>N</replaceable></option></term>
913
* <listitem><para>gtester-specific argument.</para></listitem>
916
* <term><option>--GTestSkipCount <replaceable>N</replaceable></option></term>
917
* <listitem><para>gtester-specific argument.</para></listitem>
921
* <listitem><para>Debug test logging output.</para></listitem>
918
922
* </varlistentry>
919
923
* </variablelist>
1382
find_suite (gconstpointer l, gconstpointer s)
1384
const GTestSuite *suite = l;
1385
const gchar *str = s;
1387
return strcmp (suite->name, str);
1378
1391
* GTestFixtureFunc:
1379
1392
* @fixture: the test fixture
1423
1436
continue; /* initial or duplicate slash */
1424
1437
else if (!islast)
1426
GTestSuite *csuite = g_test_create_suite (seg);
1427
g_test_suite_add_suite (suite, csuite);
1441
l = g_slist_find_custom (suite->suites, seg, find_suite);
1448
csuite = g_test_create_suite (seg);
1449
g_test_suite_add_suite (suite, csuite);
1428
1451
suite = csuite;
1430
1453
else /* islast */
1523
1546
g_return_if_fail (testpath != NULL);
1524
1547
g_return_if_fail (testpath[0] == '/');
1525
1548
g_return_if_fail (test_func != NULL);
1526
1550
g_test_add_vtable (testpath, 0, test_data, NULL, (GTestFixtureFunc) test_func, NULL);
1554
* g_test_add_data_func_full:
1555
* @testpath: /-separated test case path name for the test.
1556
* @test_data: Test data argument for the test function.
1557
* @test_func: The test function to invoke for this test.
1558
* @data_free_func: #GDestroyNotify for @test_data.
1560
* Create a new test case, as with g_test_add_data_func(), but freeing
1561
* @test_data after the test run is complete.
1566
g_test_add_data_func_full (const char *testpath,
1568
GTestDataFunc test_func,
1569
GDestroyNotify data_free_func)
1571
g_return_if_fail (testpath != NULL);
1572
g_return_if_fail (testpath[0] == '/');
1573
g_return_if_fail (test_func != NULL);
1575
g_test_add_vtable (testpath, 0, test_data, NULL,
1576
(GTestFixtureFunc) test_func,
1577
(GTestFixtureFunc) data_free_func);
1530
1581
* g_test_create_suite:
1531
1582
* @suite_name: a name for the suite
1887
1938
char *s = NULL;
1888
1940
switch (numtype)
1890
case 'i': s = g_strdup_printf ("assertion failed (%s): (%.0Lf %s %.0Lf)", expr, arg1, cmp, arg2); break;
1942
case 'i': s = g_strdup_printf ("assertion failed (%s): (%" G_GINT64_MODIFIER "i %s %" G_GINT64_MODIFIER "i)", expr, (gint64) arg1, cmp, (gint64) arg2); break;
1891
1943
case 'x': s = g_strdup_printf ("assertion failed (%s): (0x%08" G_GINT64_MODIFIER "x %s 0x%08" G_GINT64_MODIFIER "x)", expr, (guint64) arg1, cmp, (guint64) arg2); break;
1892
case 'f': s = g_strdup_printf ("assertion failed (%s): (%.9Lg %s %.9Lg)", expr, arg1, cmp, arg2); break;
1944
case 'f': s = g_strdup_printf ("assertion failed (%s): (%.9g %s %.9g)", expr, (double) arg1, cmp, (double) arg2); break;
1893
1945
/* ideally use: floats=%.7g double=%.17g */
1895
1947
g_assertion_message (domain, file, line, func, s);
1957
2009
* @str1: (allow-none): a C string or %NULL
1958
2010
* @str2: (allow-none): another C string or %NULL
1960
* Compares @str1 and @str2 like strcmp(). Handles %NULL
2012
* Compares @str1 and @str2 like strcmp(). Handles %NULL
1961
2013
* gracefully by sorting it before non-%NULL strings.
1962
2014
* Comparing two %NULL pointers returns 0.
1964
* Returns: -1, 0 or 1, if @str1 is <, == or > than @str2.
2016
* Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
2162
2214
close (stderr_pipe[0]);
2163
2215
close (stdtst_pipe[0]);
2164
2216
if (!(test_trap_flags & G_TEST_TRAP_INHERIT_STDIN))
2165
fd0 = open ("/dev/null", O_RDONLY);
2217
fd0 = g_open ("/dev/null", O_RDONLY, 0);
2166
2218
if (sane_dup2 (stdout_pipe[1], 1) < 0 || sane_dup2 (stderr_pipe[1], 2) < 0 || (fd0 >= 0 && sane_dup2 (fd0, 0) < 0))
2167
2219
g_error ("failed to dup2() in forked test program: %s", g_strerror (errno));