diff --git a/CMakeLists.txt b/CMakeLists.txt index 92e69a8e..cb08c978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,12 @@ cr_add_library(criterion SHARED VERSION ${PROJECT_SONAME} SOVERSION ${PROJECT_SOVERSION} ) +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/src/signal_names.c + PROPERTIES GENERATED TRUE + ) + +add_dependencies(criterion generate_signal_names) cr_link_subproject(criterion csptr STATIC IF NOT CSPTR_FOUND) cr_link_subproject(criterion nanomsg STATIC IF NOT NANOMSG_FOUND) @@ -225,6 +231,7 @@ add_custom_target(uninstall if (CTESTS) enable_testing() add_custom_target(criterion_tests) + add_dependencies(criterion_tests generate_signal_names) add_subdirectory(samples) add_subdirectory(test) endif () diff --git a/po/de.po b/po/de.po index 8932c6ec..cc6026a5 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Criterion \n" "Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n" -"POT-Creation-Date: 2017-07-16 19:18+0100\n" +"POT-Creation-Date: 2019-02-03 19:07+0100\n" "PO-Revision-Date: 2016-02-12 11:12+0100\n" "Last-Translator: \n" "Language-Team: German\n" @@ -18,85 +18,86 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/log/normal.c:47 +#: src/log/normal.c:48 #, c-format msgid "Criterion v%s\n" msgstr "Criterion v%s\n" -#: src/log/normal.c:48 +#: src/log/normal.c:49 #, c-format msgid " %s\n" msgstr " %s\n" -#: src/log/normal.c:51 src/log/normal.c:52 +#: src/log/normal.c:52 src/log/normal.c:53 #, c-format msgid "%1$s::%2$s\n" msgstr "%1$s::%2$s\n" -#: src/log/normal.c:53 +#: src/log/normal.c:54 #, c-format msgid "%1$s::%2$s: (%3$3.2fs)\n" msgstr "%1$s::%2$s: (%3$3.2fs)\n" -#: src/log/normal.c:54 +#: src/log/normal.c:55 #, c-format msgid "%1$s::%2$s: Test was skipped\n" msgstr "%1$s::%2$s: Test wurde übersprungen\n" -#: src/log/normal.c:55 +#: src/log/normal.c:56 #, c-format msgid "%1$s::%2$s: Test is disabled\n" msgstr "%1$s::%2$s: Test ist deaktiviert\n" -#: src/log/normal.c:56 +#: src/log/normal.c:57 #, fuzzy, c-format msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: %7$s\n" msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: %7$s\n" -#: src/log/normal.c:57 +#: src/log/normal.c:58 #, fuzzy, c-format msgid " %1$s: %2$s\n" msgstr " %1$s: %2$s\n" -#: src/log/normal.c:58 +#: src/log/normal.c:59 #, fuzzy, c-format msgid " %1$s: %2$s[-%3$s-]%4$s%5$s{+%6$s+}%7$s\n" msgstr " %1$s: %2$s[-%3$s-]%4$s%5$s{+%6$s+}%7$s\n" -#: src/log/normal.c:59 +#: src/log/normal.c:60 #, fuzzy, c-format msgid " %1$s: %2$s%3$s%4$s\n" msgstr " %1$s: %2$s%3$s%4$s\n" -#: src/log/normal.c:60 +#: src/log/normal.c:61 #, c-format msgid " Theory %1$s::%2$s failed with the following parameters: (%3$s)\n" msgstr "" " Hypothese %1$s::%2$s schlug fehl mit den folgenden Parametern: (%3$s)\n" -#: src/log/normal.c:61 +#: src/log/normal.c:62 #, c-format msgid "%1$s::%2$s: Timed out. (%3$3.2fs)\n" msgstr "%1$s::%2$s: Außerhalb der Vorgabezeit. (%3$3.2fs)\n" -#: src/log/normal.c:62 -#, c-format -msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n" +#: src/log/normal.c:63 +#, fuzzy, c-format +msgid "" +"%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal (%7$s) caught below this line!\n" msgstr "" -"%1$s%2$s%3$s:%4$s%5$u%6$s: Unerwartetes Signal gefangen unterhalb dieser " -"Zeile!\n" +"%1$s%2$s%3$s:%4$s%5$u%6$s: Unerwartetes Signal (%7$s) gefangen unterhalb " +"dieser Zeile!\n" -#: src/log/normal.c:63 +#: src/log/normal.c:64 #, c-format msgid "%1$s::%2$s: CRASH!\n" msgstr "%1$s::%2$s: ABSTURZ!\n" -#: src/log/normal.c:64 +#: src/log/normal.c:65 #, c-format msgid "%1$s::%2$s: %3$s\n" msgstr "%1$s::%2$s: %3$s\n" -#: src/log/normal.c:65 +#: src/log/normal.c:66 #, c-format msgid "" "%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown." @@ -105,7 +106,7 @@ msgstr "" "%1$sWarnung! Der Test `%2$s::%3$s` ist abgestürzt während der " "Initialisierung oder Beendung %4$s\n" -#: src/log/normal.c:66 +#: src/log/normal.c:67 #, c-format msgid "" "%1$sWarning! The test `%2$s::%3$s` exited during its setup or teardown.%4$s\n" @@ -113,14 +114,14 @@ msgstr "" "%1$sWarnung! Der Test `%2$s::%3$s` hat sich beendet während der " "Initialisierung oder Beendung.%4$s\n" -#: src/log/normal.c:67 +#: src/log/normal.c:68 #, c-format msgid "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n" msgid_plural "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n" msgstr[0] "Führe %1$s%2$lu%3$s Test durch von %4$s%5$s%6$s:\n" msgstr[1] "Führe %1$s%2$lu%3$s Tests durch von %4$s%5$s%6$s:\n" -#: src/log/normal.c:69 +#: src/log/normal.c:70 #, c-format msgid "" "%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s" @@ -129,12 +130,12 @@ msgstr "" "%1$sSynthese: Getestet: %2$s%3$lu%4$s | Bestanden: %5$s%6$lu%7$s | Fehler: " "%8$s%9$lu%10$s | Abstürze: %11$s%12$lu%13$s %14$s\n" -#: src/log/normal.c:74 +#: src/log/normal.c:75 #, fuzzy, c-format msgid "%2$*1$s%3$s%4$s%5$s\n" msgstr "%2$*1$s%3$s%4$s%5$s\n" -#: src/log/normal.c:192 +#: src/log/normal.c:193 msgid "Assertion Failed" msgstr "Fehlerhafte Behauptung" @@ -205,7 +206,7 @@ msgstr "Die Anweisung `%1$s` hat eine Instanz der Ausname `%2$s` geworfen." msgid "The statement `%1$s` did not throw an instance of the `%2$s` exception." msgstr "Die Anweisung `%1$s` hat keine Instanz der Ausname `%2$s` geworfen." -#: src/core/runner.c:68 +#: src/core/runner.c:70 #, c-format msgid "" "%1$sWarning! Criterion has detected that it is running under valgrind, but " @@ -216,13 +217,13 @@ msgstr "" "die Anzahl an Aufträgen wurde explizit festgelegt. Die Berichte können " "verwirrend sein!%2$s\n" -#: src/io/output.c:36 +#: src/io/output.c:38 #, c-format msgid "Could not open the file @ `%1$s` for %2$s reporting: %3$s.\n" msgstr "" "Konnte die Datei `%1$s` nicht für die Berichte von %2$s öffnen: %3$s.\n" -#: src/io/output.c:37 +#: src/io/output.c:39 #, c-format msgid "Writing %1$s report in `%2$s`.\n" msgstr "Schreibe Bericht von %1$s nach `%2$s`.\n" diff --git a/po/fr.po b/po/fr.po index e368e059..1261b5f3 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: criterion 2.0.0\n" "Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n" -"POT-Creation-Date: 2017-07-16 19:18+0100\n" +"POT-Creation-Date: 2019-02-02 18:12+0100\n" "PO-Revision-Date: 2015-04-03 17:58+0200\n" "Last-Translator: \n" "Language-Team: French\n" @@ -18,85 +18,86 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: src/log/normal.c:47 +#: src/log/normal.c:48 #, c-format msgid "Criterion v%s\n" msgstr "Criterion v%s\n" -#: src/log/normal.c:48 +#: src/log/normal.c:49 #, c-format msgid " %s\n" msgstr " %s\n" -#: src/log/normal.c:51 src/log/normal.c:52 +#: src/log/normal.c:52 src/log/normal.c:53 #, c-format msgid "%1$s::%2$s\n" msgstr "%1$s::%2$s\n" -#: src/log/normal.c:53 +#: src/log/normal.c:54 #, c-format msgid "%1$s::%2$s: (%3$3.2fs)\n" msgstr "%1$s::%2$s: (%3$3.2fs)\n" -#: src/log/normal.c:54 +#: src/log/normal.c:55 #, c-format msgid "%1$s::%2$s: Test was skipped\n" msgstr "%1$s::%2$s: Le test a été sauté\n" -#: src/log/normal.c:55 +#: src/log/normal.c:56 #, c-format msgid "%1$s::%2$s: Test is disabled\n" msgstr "%1$s::%2$s: Le test est désactivé\n" -#: src/log/normal.c:56 +#: src/log/normal.c:57 #, fuzzy, c-format msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: %7$s\n" msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: %7$s\n" -#: src/log/normal.c:57 +#: src/log/normal.c:58 #, fuzzy, c-format msgid " %1$s: %2$s\n" msgstr " %1$s::%2$s\n" -#: src/log/normal.c:58 +#: src/log/normal.c:59 #, fuzzy, c-format msgid " %1$s: %2$s[-%3$s-]%4$s%5$s{+%6$s+}%7$s\n" msgstr " %1$s: %2$s[-%3$s-]%4$s%5$s{+%6$s+}%7$s\n" -#: src/log/normal.c:59 +#: src/log/normal.c:60 #, fuzzy, c-format msgid " %1$s: %2$s%3$s%4$s\n" msgstr " %1$s: %2$s%3$s%4$s\n" -#: src/log/normal.c:60 +#: src/log/normal.c:61 #, fuzzy, c-format msgid " Theory %1$s::%2$s failed with the following parameters: (%3$s)\n" msgstr "" " La théorie %1$s::%2$s a échoué avec les paramètres suivants: (%3$s)\n" -#: src/log/normal.c:61 +#: src/log/normal.c:62 #, fuzzy, c-format msgid "%1$s::%2$s: Timed out. (%3$3.2fs)\n" msgstr "%1$s::%2$s: Délai expiré. (%3$3.2fs)\n" -#: src/log/normal.c:62 -#, c-format -msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n" +#: src/log/normal.c:63 +#, fuzzy, c-format +msgid "" +"%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal (%7$s) caught below this line!\n" msgstr "" -"%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu a été reçu après cette " +"%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu (%7$s) a été reçu après cette " "ligne!\n" -#: src/log/normal.c:63 +#: src/log/normal.c:64 #, c-format msgid "%1$s::%2$s: CRASH!\n" msgstr "%1$s::%2$s: PLANTAGE!\n" -#: src/log/normal.c:64 +#: src/log/normal.c:65 #, fuzzy, c-format msgid "%1$s::%2$s: %3$s\n" msgstr "%1$s::%2$s: %3$s\n" -#: src/log/normal.c:65 +#: src/log/normal.c:66 #, fuzzy, c-format msgid "" "%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown." @@ -105,7 +106,7 @@ msgstr "" "%1$sAttention! Le test `%2$s::%3$s` a planté pendant son initialisation ou " "sa finalisation.%4$s\n" -#: src/log/normal.c:66 +#: src/log/normal.c:67 #, fuzzy, c-format msgid "" "%1$sWarning! The test `%2$s::%3$s` exited during its setup or teardown.%4$s\n" @@ -113,14 +114,14 @@ msgstr "" "%1$sAttention! Le test `%2$s::%3$s` a quitté pendant son initialisation ou " "sa finalisation.%4$s\n" -#: src/log/normal.c:67 +#: src/log/normal.c:68 #, c-format msgid "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n" msgid_plural "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n" msgstr[0] "Lancement de %1$s%2$lu%3$s test dans %4$s%5$s%6$s:\n" msgstr[1] "Lancement de %1$s%2$lu%3$s tests dans %4$s%5$s%6$s:\n" -#: src/log/normal.c:69 +#: src/log/normal.c:70 #, c-format msgid "" "%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s" @@ -129,12 +130,12 @@ msgstr "" "%1$sSynthèse: Testés: %2$s%3$lu%4$s | Validés: %5$s%6$lu%7$s | Échoués: %8$s" "%9$lu%10$s | Plantages: %11$s%12$lu%13$s %14$s\n" -#: src/log/normal.c:74 +#: src/log/normal.c:75 #, fuzzy, c-format msgid "%2$*1$s%3$s%4$s%5$s\n" msgstr "%2$*1$s%3$s%4$s%5$s\n" -#: src/log/normal.c:192 +#: src/log/normal.c:193 msgid "Assertion Failed" msgstr "Échec d'assertion" @@ -207,7 +208,7 @@ msgstr "L'instruction `%1$s` a levé une instance de l'exception `%2$s`." msgid "The statement `%1$s` did not throw an instance of the `%2$s` exception." msgstr "L'instruction `%1$s` n'a pas levé d'instance de l'exception `%2$s`." -#: src/core/runner.c:68 +#: src/core/runner.c:70 #, c-format msgid "" "%1$sWarning! Criterion has detected that it is running under valgrind, but " @@ -218,13 +219,13 @@ msgstr "" "nombre de tâches est explicitement défini. Les rapports d'erreur risquent " "d'être déroutants!%2$s\n" -#: src/io/output.c:36 +#: src/io/output.c:38 #, fuzzy, c-format msgid "Could not open the file @ `%1$s` for %2$s reporting: %3$s.\n" msgstr "" "Impossible d'ouvrir le fichier `%1$s` pour faire le rapport %2$s: %3$s.\n" -#: src/io/output.c:37 +#: src/io/output.c:39 #, c-format msgid "Writing %1$s report in `%2$s`.\n" msgstr "Écriture du rapport %1$s dans `%2$s`.\n" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ca49a7fc..e288e841 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,6 +166,42 @@ configure_file( @ONLY ) +if (UNIX) + find_program(SHELL sh) + + if (SHELL) + add_custom_command ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/signal_names.c + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/signals/create_source.sh + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/signals/create_source.sh + ) + + set (SOURCE_FILES ${SOURCE_FILES} + ${CMAKE_CURRENT_BINARY_DIR}/signal_names.c + ) + + add_custom_target( + generate_signal_names + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/signal_names.c + ) + + endif (SHELL) +endif (UNIX) + +if(NOT UNIX OR NOT SHELL) + + set (SOURCE_FILES ${SOURCE_FILES} + src/signals/signal_names_default.c + ) + + add_custom_target( generate_signal_names ) + +endif() + +set(INTERFACE_FILES ${INTERFACE_FILES} + src/signals/signal_names.h + ) + install (FILES "${CMAKE_CURRENT_BINARY_DIR}/criterion.pc" DESTINATION "share/pkgconfig") set (SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) diff --git a/src/log/normal.c b/src/log/normal.c index 83883da3..68205708 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -39,6 +39,7 @@ #include "string/diff.h" #include "config.h" #include "common.h" +#include "signals/signal_names.h" #define LOG_DIFF_THRESHOLD 25 @@ -59,7 +60,7 @@ static msg_t msg_assert_eq_short = N_(" %1$s: %2$s[-%3$s-]%4$s%5$s{+%6$s+}%7$ static msg_t msg_assert_param = N_(" %1$s: %2$s%3$s%4$s\n"); static msg_t msg_theory_fail = N_(" Theory %1$s::%2$s failed with the following parameters: (%3$s)\n"); static msg_t msg_test_timeout = N_("%1$s::%2$s: Timed out. (%3$3.2fs)\n"); -static msg_t msg_test_crash_line = N_("%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"); +static msg_t msg_test_crash_line = N_("%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal (%7$s) caught below this line!\n"); static msg_t msg_test_crash = N_("%1$s::%2$s: CRASH!\n"); static msg_t msg_test_generic = N_("%1$s::%2$s: %3$s\n"); static msg_t msg_test_other_crash = N_("%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown.%4$s\n"); @@ -84,7 +85,7 @@ static msg_t msg_assert_eq_short = " %s: %s[-%s-]%s%s{+%s+}%s\n"; static msg_t msg_assert_param = " %s: %s%s%s\n"; static msg_t msg_theory_fail = " Theory %s::%s failed with the following parameters: (%s)\n"; static msg_t msg_test_timeout = "%s::%s: Timed out. (%3.2fs)\n"; -static msg_t msg_test_crash_line = "%s%s%s:%s%u%s: Unexpected signal caught below this line!\n"; +static msg_t msg_test_crash_line = "%s%s%s:%s%u%s: Unexpected signal (%s) caught below this line!\n"; static msg_t msg_test_crash = "%s::%s: CRASH!\n"; static msg_t msg_test_generic = "%s::%s: %s\n"; static msg_t msg_test_other_crash = "%sWarning! The test `%s::%s` crashed during its setup or teardown.%s\n"; @@ -123,8 +124,8 @@ void normal_log_pre_init(struct criterion_suite *suite, struct criterion_test *t void normal_log_post_test(struct criterion_test_stats *stats) { - const char *format = criterion_options.measure_time ? - msg_post_test_timed : msg_post_test; + const char *format = criterion_options.measure_time + ? msg_post_test_timed : msg_post_test; const enum criterion_logging_level level = stats->test_status == CR_STATUS_FAILED ? CRITERION_IMPORTANT : CRITERION_INFO; @@ -155,7 +156,7 @@ void normal_log_post_all(struct criterion_global_stats *stats) { size_t tested = stats->nb_tests - stats->tests_skipped; char *tests_crashed_color = (stats->tests_crashed) ? CR_FG_RED : CR_RESET; - char *tests_failed_color = (stats->tests_failed) ? CR_FG_RED : CR_RESET; + char *tests_failed_color = (stats->tests_failed) ? CR_FG_RED : CR_RESET; criterion_pimportant(CRITERION_PREFIX_EQUALS, _(msg_post_all), @@ -197,9 +198,9 @@ void normal_log_assert(struct criterion_assert_stats *stats) if (stats->message && *stats->message) { criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_desc), ""); - char *dup = strdup(stats->message); - char *saveptr = NULL; - char *line = strtok_r(dup, "\n", &saveptr); + char *dup = strdup(stats->message); + char *saveptr = NULL; + char *line = strtok_r(dup, "\n", &saveptr); do { criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_desc), line); @@ -225,9 +226,9 @@ void normal_log_assert_formatted(struct criterion_assert_stats *stats, { (void) stats; - char *dup = strdup(formatted); - char *saveptr = NULL; - char *line = strtok_r(dup, "\n", &saveptr); + char *dup = strdup(formatted); + char *saveptr = NULL; + char *line = strtok_r(dup, "\n", &saveptr); for (; line; line = strtok_r(NULL, "\n", &saveptr)) { char *color; @@ -358,7 +359,8 @@ void normal_log_test_crash(struct criterion_test_stats *stats) criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_test_crash_line), CR_FG_BOLD, sf ? basename_compat(stats->file) : stats->file, CR_RESET, - CR_FG_RED, stats->progress, CR_RESET); + CR_FG_RED, stats->progress, CR_RESET, + get_signal_name(stats->signal)); criterion_pimportant(CRITERION_PREFIX_FAIL, _(msg_test_crash), stats->test->category, stats->test->name); @@ -410,9 +412,9 @@ void normal_log_test_timeout(CR_UNUSED struct criterion_test_stats *stats) void normal_log_test_abort(CR_UNUSED struct criterion_test_stats *stats, const char *msg) { - char *dup = strdup(msg); - char *saveptr = NULL; - char *line = strtok_r(dup, "\n", &saveptr); + char *dup = strdup(msg); + char *saveptr = NULL; + char *line = strtok_r(dup, "\n", &saveptr); criterion_pimportant(CRITERION_PREFIX_DASHES, _(msg_test_generic), @@ -428,9 +430,9 @@ void normal_log_test_abort(CR_UNUSED struct criterion_test_stats *stats, const c void normal_log_message(enum criterion_severity severity, const char *msg) { - char *dup = strdup(msg); - char *saveptr = NULL; - char *line = strtok_r(dup, "\n", &saveptr); + char *dup = strdup(msg); + char *saveptr = NULL; + char *line = strtok_r(dup, "\n", &saveptr); do { if (*line != '\0') @@ -440,21 +442,21 @@ void normal_log_message(enum criterion_severity severity, const char *msg) } struct criterion_logger normal_logging = { - .log_pre_all = normal_log_pre_all, - .log_pre_init = normal_log_pre_init, - .log_pre_suite = normal_log_pre_suite, - .log_assert = normal_log_assert, - .log_assert_sub = normal_log_assert_sub, - .log_assert_param = normal_log_assert_param, - .log_assert_param_eq = normal_log_assert_param_eq, - .log_assert_formatted = normal_log_assert_formatted, - .log_theory_fail = normal_log_theory_fail, - .log_test_timeout = normal_log_test_timeout, - .log_test_crash = normal_log_test_crash, - .log_test_abort = normal_log_test_abort, - .log_other_crash = normal_log_other_crash, - .log_abnormal_exit = normal_log_abnormal_exit, - .log_post_test = normal_log_post_test, - .log_post_all = normal_log_post_all, - .log_message = normal_log_message, + .log_pre_all = normal_log_pre_all, + .log_pre_init = normal_log_pre_init, + .log_pre_suite = normal_log_pre_suite, + .log_assert = normal_log_assert, + .log_assert_sub = normal_log_assert_sub, + .log_assert_param = normal_log_assert_param, + .log_assert_param_eq = normal_log_assert_param_eq, + .log_assert_formatted = normal_log_assert_formatted, + .log_theory_fail = normal_log_theory_fail, + .log_test_timeout = normal_log_test_timeout, + .log_test_crash = normal_log_test_crash, + .log_test_abort = normal_log_test_abort, + .log_other_crash = normal_log_other_crash, + .log_abnormal_exit = normal_log_abnormal_exit, + .log_post_test = normal_log_post_test, + .log_post_all = normal_log_post_all, + .log_message = normal_log_message, }; diff --git a/src/signals/create_source.sh b/src/signals/create_source.sh new file mode 100755 index 00000000..46b726a8 --- /dev/null +++ b/src/signals/create_source.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +cat << EOF > signal_names.c +#include "signals/signal_names.h" +#include +#include + +#define BUF_SIZE 10 +char const * get_signal_name(int signal){ + static char str[BUF_SIZE]; + switch(signal){ +EOF + +for sig in `kill -l` +do + if echo $sig | grep '^[0-9]\+$' ; then + echo "case $sig: return \"$sig\";" >> signal_names.c + elif ! echo "$sig" | grep -q RTMAX\* && ! echo "$sig" | grep -q RTMIN\* ; then + echo "case SIG$sig: return \"SIG$sig\";" >> signal_names.c + fi +done + +cat << EOF >> signal_names.c + + default: + snprintf(str, BUF_SIZE, "%d", signal); + return str; + } +} +EOF diff --git a/src/signals/signal_names.h b/src/signals/signal_names.h new file mode 100644 index 00000000..befbde62 --- /dev/null +++ b/src/signals/signal_names.h @@ -0,0 +1,25 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Matthias "ailu" Günzel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +char const *get_signal_name(int signal); diff --git a/src/signals/signal_names_default.c b/src/signals/signal_names_default.c new file mode 100644 index 00000000..dcbf4ce7 --- /dev/null +++ b/src/signals/signal_names_default.c @@ -0,0 +1,46 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Matthias "ailu" Günzel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "signal_names.h" + +#define BUF_SIZE 10 + +char const *get_signal_name(int signal) +{ + static char str[BUF_SIZE]; + switch (signal) { + + case SIGABRT: return "SIGABRT"; + case SIGFPE: return "SIGFPE"; + case SIGILL: return "SIGILL"; + case SIGINT: return "SIGINT"; + case SIGSEGV: return "SIGSEGV"; + case SIGTERM: return "SIGTERM"; + default: + snprintf(str, BUF_SIZE, "%d", signal); + return str; + } +} diff --git a/test/cram/crashes.t b/test/cram/crashes.t index 360a60c1..49c340e0 100644 --- a/test/cram/crashes.t +++ b/test/cram/crashes.t @@ -1,13 +1,13 @@ Simple crashes & signal testing $ signal.c.bin - [----] signal.c:14: Unexpected signal caught below this line! + [----] signal.c:14: Unexpected signal (SIGSEGV) caught below this line! [FAIL] simple::uncaught: CRASH! [FAIL] simple::wrong_signal [====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1 $ signal.cc.bin - [----] signal.cc:14: Unexpected signal caught below this line! + [----] signal.cc:14: Unexpected signal (SIGSEGV) caught below this line! [FAIL] simple::uncaught: CRASH! [FAIL] simple::wrong_signal [====] Synthesis: Tested: 3 | Passing: 1 | Failing: 2 | Crashing: 1 @@ -20,7 +20,7 @@ Simple crashes & signal testing (verbose) [RUN ] simple::caught [PASS] simple::caught [RUN ] simple::uncaught - [----] signal.c:14: Unexpected signal caught below this line! + [----] signal.c:14: Unexpected signal (SIGSEGV) caught below this line! [FAIL] simple::uncaught: CRASH! [RUN ] simple::wrong_signal [FAIL] simple::wrong_signal @@ -32,7 +32,7 @@ Simple crashes & signal testing (verbose) [RUN ] simple::caught [PASS] simple::caught [RUN ] simple::uncaught - [----] signal.cc:14: Unexpected signal caught below this line! + [----] signal.cc:14: Unexpected signal (SIGSEGV) caught below this line! [FAIL] simple::uncaught: CRASH! [RUN ] simple::wrong_signal [FAIL] simple::wrong_signal