|
From: <mat...@us...> - 2014-04-06 22:19:39
|
Revision: 541
http://sourceforge.net/p/cgreen/code/541
Author: matt_hargett
Date: 2014-04-06 22:19:30 +0000 (Sun, 06 Apr 2014)
Log Message:
-----------
fix win32 and cygwin builds. thanks to Dirk Jagdmann for the patch
Modified Paths:
--------------
trunk/cgreen/cmake/Modules/DefineCompilerFlags.cmake
trunk/cgreen/include/cgreen/assertions.h
trunk/cgreen/include/cgreen/cpp_constraint.h
trunk/cgreen/include/cgreen/internal/cpp_assertions.h
trunk/cgreen/src/cdash_reporter.c
trunk/cgreen/src/constraint.c
trunk/cgreen/src/messaging.c
trunk/cgreen/src/posix_cgreen_pipe.c
trunk/cgreen/src/reporter.c
trunk/cgreen/src/text_reporter.c
trunk/cgreen/src/win32_runner_platform.c
trunk/cgreen/tests/all_constraints_printout.c
Modified: trunk/cgreen/cmake/Modules/DefineCompilerFlags.cmake
===================================================================
--- trunk/cgreen/cmake/Modules/DefineCompilerFlags.cmake 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/cmake/Modules/DefineCompilerFlags.cmake 2014-04-06 22:19:30 UTC (rev 541)
@@ -60,3 +60,10 @@
endif (WITH_FORTIFY_SOURCE)
endif (CMAKE_COMPILER_IS_GNUCC OR COMPILER_IS_CLANG)
endif (UNIX)
+
+if (WIN32)
+ if (MSVC)
+ add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
+ endif (MSVC)
+endif (WIN32)
+
Modified: trunk/cgreen/include/cgreen/assertions.h
===================================================================
--- trunk/cgreen/include/cgreen/assertions.h 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/include/cgreen/assertions.h 2014-04-06 22:19:30 UTC (rev 541)
@@ -15,6 +15,8 @@
#endif
#ifdef __cplusplus
+#include <cgreen/cpp_assertions.h>
+
namespace cgreen {
extern "C" {
#endif
Modified: trunk/cgreen/include/cgreen/cpp_constraint.h
===================================================================
--- trunk/cgreen/include/cgreen/cpp_constraint.h 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/include/cgreen/cpp_constraint.h 2014-04-06 22:19:30 UTC (rev 541)
@@ -1,3 +1,7 @@
+#ifndef CGREEN_CPP_CONSTRAINT
+#define CGREEN_CPP_CONSTRAINT
+
+
#include <cgreen/constraint.h>
#include <string>
@@ -3,4 +7,10 @@
namespace cgreen {
+template<typename T>
+class CppConstraint : public Constraint {
+ T expected_real_value;
+ bool (*compare)(CppConstraint *, T);
+};
+
Constraint *create_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name);
Constraint *create_not_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name);
@@ -12,6 +22,37 @@
Constraint *create_contains_string_constraint(const std::string* expected_value, const char *expected_value_name);
Constraint *create_does_not_contain_string_constraint(const std::string* expected_value, const char *expected_value_name);
+template<typename T>
+bool compare_want_value(CppConstraint<T> *constraint, T actual) {
+ return constraint->expected_real_value == actual;
+}
+
+template<typename T>
+bool compare_do_not_want_value(CppConstraint<T> *constraint, T actual) {
+ return !compare_want_value(constraint, actual);
+}
+
+template<typename T>
+void test_want_value(CppConstraint<T> *constraint, const char *function, T actual, const char *test_file, int test_line, TestReporter *reporter) {
+}
+
// TODO: add create_equal_to_constraint_<T> where operator<< output is used for expected_value name
+template<typename T>
+CppConstraint<T> *create_equal_to_value_constraint(T expected_value, const char *expected_value_name) {
+ CppConstraint<T> *constraint;// = create_cpp_constraint<T>();
+ constraint->type = VALUE_COMPARER;
+ constraint->compare = &compare_want_value;
+ constraint->execute = &test_want;
+ constraint->name = "equal";
+ constraint->expected_value = expected_value;
+ constraint->expected_value_name = expected_value_name;
+ constraint->size_of_expected_value = sizeof(intptr_t);
+ constraint->real_expected_value = expected_value;
+ return constraint;
}
+
+
+}
+
+#endif
Modified: trunk/cgreen/include/cgreen/internal/cpp_assertions.h
===================================================================
--- trunk/cgreen/include/cgreen/internal/cpp_assertions.h 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/include/cgreen/internal/cpp_assertions.h 2014-04-06 22:19:30 UTC (rev 541)
@@ -1,5 +1,5 @@
-#ifndef CPP_ASSERTIONS_HEADER
-#define CPP_ASSERTIONS_HEADER
+#ifndef INTERNAL_CPP_ASSERTIONS_HEADER
+#define INTERNAL_CPP_ASSERTIONS_HEADER
#include <cgreen/constraint.h>
#include <stdint.h>
Modified: trunk/cgreen/src/cdash_reporter.c
===================================================================
--- trunk/cgreen/src/cdash_reporter.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/cdash_reporter.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -96,7 +96,7 @@
fclose(fd);
- strsize = snprintf(reporter_path, 255, "./Testing/%s", sbuildstamp);
+ strsize = snprintf(reporter_path, sizeof(reporter_path) - 1, "./Testing/%s", sbuildstamp);
rep_dir = mkdir(reporter_path, S_IXUSR|S_IRUSR|S_IWUSR|S_IXGRP|S_IRGRP|S_IXOTH);
Modified: trunk/cgreen/src/constraint.c
===================================================================
--- trunk/cgreen/src/constraint.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/constraint.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -13,6 +13,10 @@
#include <stdlib.h>
#include <string.h>
+#ifdef _MSC_VER
+#include "wincompat.h"
+#endif
+
#ifdef __cplusplus
namespace cgreen {
#endif
@@ -369,7 +373,7 @@
return;
}
- sprintf(parameter_name_actual_string, "[%s] parameter in [%s]", constraint->parameter_name, function);
+ snprintf(parameter_name_actual_string, sizeof(parameter_name_actual_string) - 1, "[%s] parameter in [%s]", constraint->parameter_name, function);
message = constraint->failure_message(constraint, parameter_name_actual_string, actual);
(*reporter->assert_true)(
Modified: trunk/cgreen/src/messaging.c
===================================================================
--- trunk/cgreen/src/messaging.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/messaging.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -96,7 +96,9 @@
}
void send_cgreen_message(int messaging, int result) {
- CgreenMessage *message = (CgreenMessage *) malloc(sizeof(CgreenMessage));
+ CgreenMessage *message;
+
+ message = (CgreenMessage *) malloc(sizeof(CgreenMessage));
if (message == NULL) {
return;
}
@@ -129,8 +131,8 @@
int i;
for (i = 0; i < queue_count; i++) {
if (queues[i].owner == getpid()) {
- cgreen_pipe_close(queues[i].readpipe);
- cgreen_pipe_close(queues[i].writepipe);
+ cgreen_pipe_close(queues[i].readpipe);
+ cgreen_pipe_close(queues[i].writepipe);
}
}
free(queues);
Modified: trunk/cgreen/src/posix_cgreen_pipe.c
===================================================================
--- trunk/cgreen/src/posix_cgreen_pipe.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/posix_cgreen_pipe.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -3,6 +3,12 @@
#include <unistd.h>
#include <stdio.h>
+#ifndef O_ASYNC
+# define O_ASYNC FASYNC
+# ifndef FASYNC
+# error "Your POSIX platform does not support ASYNC pipe reads. Please report a bug to cgr...@li..."
+# endif
+#endif
#ifdef __cplusplus
namespace cgreen {
@@ -21,7 +27,7 @@
ssize_t cgreen_pipe_read(int p, void *buf, size_t count)
{
- if (0 != fcntl(p, F_SETFL, O_NONBLOCK)) {
+ if (0 != fcntl(p, F_SETFL, O_ASYNC)) {
fprintf(stderr, "could not set file status flag on read pipe\n");
return -1;
}
Modified: trunk/cgreen/src/reporter.c
===================================================================
--- trunk/cgreen/src/reporter.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/reporter.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -1,6 +1,7 @@
#include <cgreen/reporter.h>
#include <cgreen/messaging.h>
#include <cgreen/breadcrumb.h>
+#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#ifndef __cplusplus
@@ -153,10 +154,13 @@
(void)arguments;
}
+static const unsigned int MAX_ASSERTIONS_PER_TEST = 8100;
+
static void assert_true(TestReporter *reporter, const char *file, int line, int result, const char *message, ...) {
va_list arguments;
+ memset(&arguments, 0, sizeof(va_list));
+
va_start(arguments, message);
-
if (result) {
(*reporter->show_pass)(reporter, file, line, message, arguments);
} else {
Modified: trunk/cgreen/src/text_reporter.c
===================================================================
--- trunk/cgreen/src/text_reporter.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/text_reporter.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -7,10 +7,10 @@
#include <stdbool.h>
#endif
-#define GREEN "\e[32m"
-#define RED "\e[31m"
-#define MAGENTA "\e[35m"
-#define RESET "\e[0m"
+#define GREEN "\x1b[32m"
+#define RED "\x1b[31m"
+#define MAGENTA "\x1b[35m"
+#define RESET "\x1b[0m"
#ifdef __cplusplus
@@ -72,9 +72,9 @@
if (reporter->options && ((TextReporterOptions *)reporter->options)->use_colours)
printf("Completed \"%s\": %s%d pass%s%s, %s%d failure%s%s, %s%d exception%s%s.\n",
name,
- reporter->passes>0?GREEN:"", reporter->passes, reporter->passes == 1 ? "" : "es", RESET,
- reporter->failures>0?RED:"", reporter->failures, reporter->failures == 1 ? "" : "s", RESET,
- reporter->exceptions>0?MAGENTA:"", reporter->exceptions, reporter->exceptions == 1 ? "" : "s", RESET);
+ (reporter->passes > 0) ? GREEN : "", reporter->passes, reporter->passes == 1 ? "" : "es", RESET,
+ (reporter->failures > 0) ? RED : "", reporter->failures, reporter->failures == 1 ? "" : "s", RESET,
+ (reporter->exceptions > 0) ? MAGENTA : "", reporter->exceptions, reporter->exceptions == 1 ? "" : "s", RESET);
else
printf("Completed \"%s\": %d pass%s, %d failure%s, %d exception%s.\n",
name, reporter->passes, reporter->passes == 1 ? "" : "es",
Modified: trunk/cgreen/src/win32_runner_platform.c
===================================================================
--- trunk/cgreen/src/win32_runner_platform.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/src/win32_runner_platform.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -71,7 +71,7 @@
//best solution for this.
reporter_start(reporter, testName); //add breadcrumb without triggering output to console
run_named_test_child(suite, testName, reporter);
- reporter_finish(reporter, suite->filename, suite->line);
+ reporter_finish(reporter, suite->filename, suite->line, NULL);
return; //never happens because we call stop inside run_named_test_child
}
@@ -147,7 +147,7 @@
success = CreateProcessA(fname, NULL, NULL, NULL, true, NORMAL_PRIORITY_CLASS , p_environment, NULL, &siStartupInfo, &piProcessInfo);
dispose_environment(p_environment);
WaitForSingleObject(piProcessInfo.hProcess,INFINITE);
- (*reporter->finish_test)(reporter, test->filename, test->line);
+ (*reporter->finish_test)(reporter, test->filename, test->line, NULL);
return;
}
Modified: trunk/cgreen/tests/all_constraints_printout.c
===================================================================
--- trunk/cgreen/tests/all_constraints_printout.c 2014-04-06 16:55:59 UTC (rev 540)
+++ trunk/cgreen/tests/all_constraints_printout.c 2014-04-06 22:19:30 UTC (rev 541)
@@ -130,7 +130,7 @@
}
Ensure(FailureMessage, increments_exception_count_when_terminating_via_SIGQUIT) {
- raise(SIGQUIT);
+ raise(SIGTERM);
}
#ifdef __cplusplus
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|