summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dimension/main.c27
-rw-r--r--dimension/realize.c10
-rw-r--r--libdimension/dimension/error.h55
-rw-r--r--libdimension/error.c93
-rw-r--r--libdimension/malloc.c6
-rw-r--r--libdimension/platform.c8
-rw-r--r--libdimension/profile.c22
-rw-r--r--libdimension/progress.c47
-rw-r--r--libdimension/raytrace.c2
-rw-r--r--libdimension/threads.c9
-rwxr-xr-xtests/dimension/arithexp.sh4
-rwxr-xr-xtests/dimension/csg.sh6
-rwxr-xr-xtests/dimension/demo.sh6
-rwxr-xr-xtests/dimension/directives.sh4
-rwxr-xr-xtests/dimension/integer-overflow.sh4
-rwxr-xr-xtests/dimension/invalid-macro.sh4
-rwxr-xr-xtests/dimension/labels.sh4
-rwxr-xr-xtests/dimension/numeric.sh4
-rwxr-xr-xtests/dimension/punctuation.sh4
-rwxr-xr-xtests/dimension/strings.sh4
-rwxr-xr-xtests/dimension/tbuffer-overlap.sh4
-rwxr-xr-xtests/dimension/transformations.sh6
-rw-r--r--tests/libdimension/Makefile.am16
-rw-r--r--tests/libdimension/cxx.cpp3
-rw-r--r--tests/libdimension/error.c6
-rw-r--r--tests/libdimension/gl.c6
-rw-r--r--tests/libdimension/list.c4
-rw-r--r--tests/libdimension/png.c6
-rw-r--r--tests/libdimension/polynomial.c4
-rw-r--r--tests/libdimension/prtree.c4
-rw-r--r--tests/libdimension/render.c4
-rw-r--r--tests/libdimension/warning-as-error.c31
-rw-r--r--tests/libdimension/warning.c31
33 files changed, 201 insertions, 247 deletions
diff --git a/dimension/main.c b/dimension/main.c
index f8b86b4..feeb6db 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of Dimension. *
* *
@@ -50,7 +50,7 @@ main(int argc, char **argv)
DMNSN_OPT_VERSION = 256,
DMNSN_OPT_THREADS,
DMNSN_OPT_QUALITY,
- DMNSN_OPT_RESILIENCE
+ DMNSN_OPT_STRICT
};
static struct option long_options[] = {
@@ -61,7 +61,7 @@ main(int argc, char **argv)
{ "height", required_argument, NULL, 'h' },
{ "threads", required_argument, NULL, DMNSN_OPT_THREADS },
{ "quality", required_argument, NULL, DMNSN_OPT_QUALITY },
- { "resilience", required_argument, NULL, DMNSN_OPT_RESILIENCE },
+ { "strict", no_argument, NULL, DMNSN_OPT_STRICT },
{ "tokenize", no_argument, &tokenize, 1 },
{ "parse", no_argument, &parse, 1 },
{ 0, 0, 0, 0 }
@@ -142,21 +142,9 @@ main(int argc, char **argv)
}
break;
}
- case DMNSN_OPT_RESILIENCE:
- {
- if (strcmp(optarg, "low") == 0) {
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
- } else if (strcmp(optarg, "medium") == 0) {
- dmnsn_set_resilience(DMNSN_SEVERITY_MEDIUM);
- } else if (strcmp(optarg, "high") == 0) {
- dmnsn_set_resilience(DMNSN_SEVERITY_HIGH);
- } else {
- fprintf(stderr, "Invalid argument to --resilience!\n");
- print_usage(stderr, argv[0]);
- return EXIT_FAILURE;
- }
- break;
- }
+ case DMNSN_OPT_STRICT:
+ dmnsn_die_on_warnings(true);
+ break;
default:
fprintf(stderr, "Invalid command line option!\n");
@@ -370,8 +358,7 @@ print_usage(FILE *file, const char *arg0)
" Rendering options:\n"
" --threads=THREADS render with THREADS parallel threads\n"
" --quality=QUALITY use the quality setting QUALITY\n"
- " --resilience=RES set error tolerance to RES (low, medium, or"
- " high)\n\n"
+ " --strict treat warnings as errors\n"
" Debugging options:\n"
" --tokenize tokenize the input and print the token list\n"
" --parse parse the input and print the abstract syntax"
diff --git a/dimension/realize.c b/dimension/realize.c
index 56bd846..8bb5c9a 100644
--- a/dimension/realize.c
+++ b/dimension/realize.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of Dimension. *
* *
@@ -36,7 +36,7 @@ dmnsn_realize_integer(dmnsn_astnode astnode)
feclearexcept(FE_ALL_EXCEPT);
long ret = lrint(*(double *)astnode.ptr);
if (fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW))
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Float out of range of integer.");
+ dmnsn_error("Float out of range of integer.");
return ret;
}
@@ -742,8 +742,7 @@ dmnsn_realize_pigment(dmnsn_astnode astnode)
const char *path = dmnsn_realize_str(strnode);
FILE *file = fopen(path, "rb");
if (!file) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't open image file.");
- return NULL;
+ dmnsn_error("Couldn't open image file.");
}
dmnsn_canvas *canvas;
@@ -751,8 +750,7 @@ dmnsn_realize_pigment(dmnsn_astnode astnode)
case DMNSN_AST_PNG:
canvas = dmnsn_png_read_canvas(file);
if (!canvas) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Invalid PNG file.");
- return NULL;
+ dmnsn_error("Invalid PNG file.");
}
pigment = dmnsn_new_canvas_pigment(canvas);
break;
diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h
index e2fd612..db4197b 100644
--- a/libdimension/dimension/error.h
+++ b/libdimension/dimension/error.h
@@ -29,24 +29,21 @@
#ifndef DIMENSION_ERROR_H
#define DIMENSION_ERROR_H
-/** Error severity codes. */
-typedef enum dmnsn_severity {
- DMNSN_SEVERITY_LOW, /**< Only die on low resilience. */
- DMNSN_SEVERITY_MEDIUM, /**< Die on low or medium resilience. */
- DMNSN_SEVERITY_HIGH /**< Always die. */
-} dmnsn_severity;
+#include <stdbool.h>
+
+/**
+ * Report a warning.
+ * @param[in] str A string to print explaining the warning.
+ */
+#define dmnsn_warning(str) \
+ dmnsn_report_error(false, DMNSN_FUNC, __FILE__, __LINE__, str)
/**
* Report an error.
- * @param[in] severity A @ref dmnsn_severity representing the severity of the
- * error. DMNSN_SEVERITY_HIGH will always terminate the
- * running thread.
* @param[in] str A string to print explaining the error.
*/
-#define dmnsn_error(severity, str) \
- dmnsn_report_error((dmnsn_severity)(severity), \
- DMNSN_FUNC, __FILE__, __LINE__, \
- str)
+#define dmnsn_error(str) \
+ dmnsn_report_error(true, DMNSN_FUNC, __FILE__, __LINE__, str)
/**
* @def dmnsn_assert
@@ -60,36 +57,28 @@ typedef enum dmnsn_severity {
#define dmnsn_assert(expr, str) \
do { \
if (!(expr)) { \
- dmnsn_error(DMNSN_SEVERITY_HIGH, (str)); \
+ dmnsn_error((str)); \
} \
} while (0)
#endif
/**
* @internal
- * Called by dmnsn_error(); don't call directly.
- * @param[in] severity The severity of the error.
- * @param[in] func The name of the function where the error originated.
- * @param[in] file The file where the error originated.
- * @param[in] line The line number where the error originated.
- * @param[in] str A string describing the error.
- */
-void dmnsn_report_error(dmnsn_severity severity,
- const char *func, const char *file, unsigned int line,
- const char *str);
-
-/**
- * Get the library resilience, thread-safely.
- * @return The error severity considered fatal.
+ * Called by dmnsn_warning() and dmnsn_error(); don't call directly.
+ * @param[in] die Whether the error is fatal.
+ * @param[in] func The name of the function where the error originated.
+ * @param[in] file The file where the error originated.
+ * @param[in] line The line number where the error originated.
+ * @param[in] str A string describing the error.
*/
-dmnsn_severity dmnsn_get_resilience(void);
+void dmnsn_report_error(bool die, const char *func, const char *file,
+ unsigned int line, const char *str);
/**
- * Set the library resilience, thread-safely.
- * @param[in] resilience The new minimum severity that will cause a fatal
- * error.
+ * Treat warnings as errors.
+ * @param[in] always_die Whether to die on warnings.
*/
-void dmnsn_set_resilience(dmnsn_severity resilience);
+void dmnsn_die_on_warnings(bool always_die);
/**
* Fatal error callback type. This function should never return.
diff --git a/libdimension/error.c b/libdimension/error.c
index 974503a..b83dec4 100644
--- a/libdimension/error.c
+++ b/libdimension/error.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -37,78 +37,55 @@ static dmnsn_fatal_error_fn *dmnsn_fatal = &dmnsn_default_fatal_error_fn;
static pthread_mutex_t dmnsn_fatal_mutex = PTHREAD_MUTEX_INITIALIZER;
/** The current resilience. */
-static dmnsn_severity dmnsn_resilience = DMNSN_SEVERITY_MEDIUM;
-/** Mutex which protexts \c dmnsn_resilience. */
-static pthread_mutex_t dmnsn_resilience_mutex = PTHREAD_MUTEX_INITIALIZER;
+static bool dmnsn_always_die = false;
+/** Mutex which protexts \c dmnsn_always_die. */
+static pthread_mutex_t dmnsn_always_die_mutex = PTHREAD_MUTEX_INITIALIZER;
-/* Called by dmnsn_error macro (don't call directly). */
+/* Called by dmnsn_error macro (don't call directly) */
void
-dmnsn_report_error(dmnsn_severity severity,
- const char *func, const char *file, unsigned int line,
- const char *str)
+dmnsn_report_error(bool die, const char *func, const char *file,
+ unsigned int line, const char *str)
{
- if (severity >= dmnsn_get_resilience()) {
- /* An error more severe than our resilience happened, bail out */
- fprintf(stderr, "Dimension ERROR: %s, %s:%u: %s\n",
- func, file, line, str);
- dmnsn_fatal_error_fn *fatal = dmnsn_get_fatal_error_fn();
- (*fatal)();
- exit(EXIT_FAILURE); /* Failsafe in case *dmnsn_fatal doesn't exit */
- } else {
- /* A trivial error happened, warn and continue */
- fprintf(stderr, "Dimension WARNING: %s, %s:%u: %s\n",
- func, file, line, str);
- }
-}
-
-/* Return the current resilience, thread-safely. */
-dmnsn_severity
-dmnsn_get_resilience(void)
-{
- dmnsn_severity resilience;
- if (pthread_mutex_lock(&dmnsn_resilience_mutex) != 0) {
- /* Couldn't lock the mutex, so warn and continue. */
- fprintf(stderr, "Dimension WARNING: %s, line %u: %s\n",
+ if (pthread_mutex_lock(&dmnsn_always_die_mutex) != 0) {
+ fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n",
DMNSN_FUNC, __LINE__,
- "Couldn't lock resilience mutex.");
+ "Couldn't lock mutex.");
+ exit(EXIT_FAILURE);
}
- resilience = dmnsn_resilience; /* Copy the static variable to a local */
- if (pthread_mutex_unlock(&dmnsn_resilience_mutex) != 0) {
- /* Couldn't unlock the mutex, so warn and continue. If the mutex was locked
- earlier, the next dmnsn_get/set_resilience is likely to hang. */
- fprintf(stderr, "Dimension WARNING: %s, line %u: %s\n",
+ bool always_die = dmnsn_always_die;
+ if (pthread_mutex_unlock(&dmnsn_always_die_mutex) != 0) {
+ fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n",
DMNSN_FUNC, __LINE__,
- "Couldn't unlock resilience mutex.");
+ "Couldn't unlock mutex.");
+ exit(EXIT_FAILURE);
}
- return resilience;
-}
-/* Set the resilience, thread-safely */
-void
-dmnsn_set_resilience(dmnsn_severity resilience)
-{
- if (resilience < DMNSN_SEVERITY_LOW || resilience > DMNSN_SEVERITY_HIGH) {
- /* Tried to set an illegal resilience, bail out */
- fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n", DMNSN_FUNC, __LINE__,
- "Resilience has wrong value.");
+ fprintf(stderr, "Dimension %s: %s, %s:%u: %s\n",
+ die ? "ERROR" : "WARNING", func, file, line, str);
+
+ if (die || always_die) {
+ /* An error happened, bail out */
dmnsn_fatal_error_fn *fatal = dmnsn_get_fatal_error_fn();
(*fatal)();
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE); /* Failsafe in case *dmnsn_fatal doesn't exit */
}
+}
- if (pthread_mutex_lock(&dmnsn_resilience_mutex) != 0) {
- /* Couldn't lock the mutex, so warn and continue. */
- fprintf(stderr, "Dimension WARNING: %s, line %u: %s\n",
+void
+dmnsn_die_on_warnings(bool always_die)
+{
+ if (pthread_mutex_lock(&dmnsn_always_die_mutex) != 0) {
+ fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n",
DMNSN_FUNC, __LINE__,
- "Couldn't lock resilience mutex.");
+ "Couldn't lock mutex.");
+ exit(EXIT_FAILURE);
}
- dmnsn_resilience = resilience;
- if (pthread_mutex_unlock(&dmnsn_resilience_mutex) != 0) {
- /* Couldn't unlock the mutex, so warn and continue. If the mutex was locked
- earlier, the next dmnsn_get/set_resilience is likely to hang. */
- fprintf(stderr, "Dimension WARNING: %s, line %u: %s\n",
+ dmnsn_always_die = always_die;
+ if (pthread_mutex_unlock(&dmnsn_always_die_mutex) != 0) {
+ fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n",
DMNSN_FUNC, __LINE__,
- "Couldn't unlock resilience mutex.");
+ "Couldn't unlock mutex.");
+ exit(EXIT_FAILURE);
}
}
diff --git a/libdimension/malloc.c b/libdimension/malloc.c
index f5666a0..e9dbd1e 100644
--- a/libdimension/malloc.c
+++ b/libdimension/malloc.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2010-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -32,7 +32,7 @@ dmnsn_malloc(size_t size)
{
void *ptr = malloc(size);
if (!ptr) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Memory allocation failed.");
+ dmnsn_error("Memory allocation failed.");
}
return ptr;
}
@@ -42,7 +42,7 @@ dmnsn_realloc(void *ptr, size_t size)
{
ptr = realloc(ptr, size);
if (!ptr) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Memory allocation failed.");
+ dmnsn_error("Memory allocation failed.");
}
return ptr;
}
diff --git a/libdimension/platform.c b/libdimension/platform.c
index a678cf4..1039ac7 100644
--- a/libdimension/platform.c
+++ b/libdimension/platform.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2010-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -87,7 +87,7 @@ dmnsn_ncpus(void)
if (sched_getaffinity(0, sizeof(cpuset), &cpuset) == 0) {
return CPU_COUNT(&cpuset);
} else {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "sched_getaffinity() failed.");
+ dmnsn_warning("sched_getaffinity() failed.");
return 1;
}
#elif DMNSN_SC_NPROCESSORS_ONLN
@@ -95,7 +95,7 @@ dmnsn_ncpus(void)
if (nprocs > 0) {
return nprocs;
} else {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "sysconf(_SC_NPROCESSORS_ONLN) failed.");
+ dmnsn_warning("sysconf(_SC_NPROCESSORS_ONLN) failed.");
return 1;
}
#elif defined(_WIN32)
@@ -120,7 +120,7 @@ dmnsn_get_times(dmnsn_timer *timer)
if (!clk_tck) {
clk_tck = sysconf(_SC_CLK_TCK);
if (clk_tck == -1) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "sysconf(_SC_CLK_TCK) failed.");
+ dmnsn_warning("sysconf(_SC_CLK_TCK) failed.");
clk_tck = 1000000L;
}
}
diff --git a/libdimension/profile.c b/libdimension/profile.c
index dd680db..cb94cc4 100644
--- a/libdimension/profile.c
+++ b/libdimension/profile.c
@@ -66,11 +66,11 @@ dmnsn_delete_thread_profile(void *ptr)
dmnsn_dictionary *thread_profile = ptr;
if (pthread_mutex_lock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't lock mutex.");
+ dmnsn_error("Couldn't lock mutex.");
}
dmnsn_dictionary_apply(thread_profile, &dmnsn_profile_globalize);
if (pthread_mutex_unlock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't unlock mutex.");
+ dmnsn_error("Couldn't unlock mutex.");
}
dmnsn_delete_dictionary(thread_profile);
@@ -84,15 +84,15 @@ dmnsn_initialize_thread_profile(void)
&dmnsn_delete_thread_profile)
!= 0)
{
- dmnsn_error(DMNSN_SEVERITY_HIGH, "pthread_key_create() failed.");
+ dmnsn_error("pthread_key_create() failed.");
}
if (pthread_mutex_lock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't lock mutex.");
+ dmnsn_error("Couldn't lock mutex.");
}
dmnsn_profile = dmnsn_new_dictionary(sizeof(dmnsn_branch));
if (pthread_mutex_unlock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't unlock mutex.");
+ dmnsn_error("Couldn't unlock mutex.");
}
}
@@ -104,7 +104,7 @@ dmnsn_get_thread_profile(void)
&dmnsn_initialize_thread_profile)
!= 0)
{
- dmnsn_error(DMNSN_SEVERITY_HIGH, "pthread_once() failed.");
+ dmnsn_error("pthread_once() failed.");
}
return pthread_getspecific(dmnsn_thread_profile);
@@ -115,7 +115,7 @@ static void
dmnsn_set_thread_profile(dmnsn_dictionary *thread_profile)
{
if (pthread_setspecific(dmnsn_thread_profile, thread_profile) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "pthread_setspecific() failed.");
+ dmnsn_error("pthread_setspecific() failed.");
}
}
@@ -125,12 +125,12 @@ dmnsn_expect(bool result, bool expected, const char *func, const char *file,
{
int size = snprintf(NULL, 0, "%s:%s:%u", file, func, line) + 1;
if (size < 1) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "sprintf() failed.");
+ dmnsn_error("sprintf() failed.");
}
char key[size];
if (snprintf(key, size, "%s:%s:%u", file, func, line) < 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "sprintf() failed.");
+ dmnsn_error("sprintf() failed.");
}
dmnsn_dictionary *thread_profile = dmnsn_get_thread_profile();
@@ -181,12 +181,12 @@ dmnsn_print_bad_predictions(void)
}
if (pthread_mutex_lock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't lock mutex.");
+ dmnsn_error("Couldn't lock mutex.");
}
dmnsn_dictionary_apply(dmnsn_profile, &dmnsn_print_bad_prediction);
dmnsn_delete_dictionary(dmnsn_profile);
dmnsn_profile = NULL;
if (pthread_mutex_unlock(&dmnsn_profile_mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't unlock mutex.");
+ dmnsn_error("Couldn't unlock mutex.");
}
}
diff --git a/libdimension/progress.c b/libdimension/progress.c
index 99b4b3c..96940e2 100644
--- a/libdimension/progress.c
+++ b/libdimension/progress.c
@@ -45,17 +45,17 @@ dmnsn_new_progress(void)
progress->rwlock = dmnsn_malloc(sizeof(pthread_rwlock_t));
if (pthread_rwlock_init(progress->rwlock, NULL) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't initialize read-write lock.");
+ dmnsn_error("Couldn't initialize read-write lock.");
}
progress->cond = dmnsn_malloc(sizeof(pthread_cond_t));
if (pthread_cond_init(progress->cond, NULL) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't initialize condition variable.");
+ dmnsn_error("Couldn't initialize condition variable.");
}
progress->mutex = dmnsn_malloc(sizeof(pthread_mutex_t));
if (pthread_mutex_init(progress->mutex, NULL) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't initialize mutex.");
+ dmnsn_error("Couldn't initialize mutex.");
}
progress->min_wait = 1.0;
@@ -74,9 +74,7 @@ dmnsn_finish_progress(dmnsn_progress *progress)
if (progress) {
/* Get the thread's return value */
if (pthread_join(progress->thread, &ptr) != 0) {
- /* Medium severity because an unjoined thread likely means that the thread
- is incomplete or invalid */
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Joining worker thread failed.");
+ dmnsn_error("Joining worker thread failed.");
} else if (ptr) {
retval = *(int *)ptr;
dmnsn_free(ptr);
@@ -84,13 +82,13 @@ dmnsn_finish_progress(dmnsn_progress *progress)
/* Free the progress object */
if (pthread_rwlock_destroy(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking rwlock.");
+ dmnsn_warning("Leaking rwlock.");
}
if (pthread_mutex_destroy(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking mutex.");
+ dmnsn_warning("Leaking mutex.");
}
if (pthread_cond_destroy(progress->cond) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
+ dmnsn_warning("Leaking condition variable.");
}
dmnsn_free(progress->rwlock);
dmnsn_free(progress->mutex);
@@ -118,25 +116,22 @@ dmnsn_get_progress(const dmnsn_progress *progress)
void
dmnsn_wait_progress(const dmnsn_progress *progress, double prog)
{
- if (pthread_mutex_lock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't lock condition mutex.");
- /* Busy-wait if we can't use the condition variable */
- while (dmnsn_get_progress(progress) < prog);
- } else {
+ if (pthread_mutex_lock(progress->mutex) == 0) {
while (dmnsn_get_progress(progress) < prog) {
/* Set the minimum waited-on value */
if (prog < progress->min_wait)
*progress->min_waitp = prog;
if (pthread_cond_wait(progress->cond, progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW,
- "Couldn't wait on condition variable.");
+ dmnsn_error("Couldn't wait on condition variable.");
}
}
if (pthread_mutex_unlock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't unlock condition mutex.");
+ dmnsn_error("Couldn't unlock condition mutex.");
}
+ } else {
+ dmnsn_error("Couldn't lock condition mutex.");
}
}
@@ -158,19 +153,19 @@ dmnsn_increment_progress(dmnsn_progress *progress)
dmnsn_progress_unlock(progress);
if (pthread_mutex_lock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't lock condition mutex.");
+ dmnsn_error("Couldn't lock condition mutex.");
}
if (dmnsn_get_progress(progress) >= progress->min_wait) {
progress->min_wait = 1.0;
if (pthread_cond_broadcast(progress->cond) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't signal condition variable.");
+ dmnsn_error("Couldn't signal condition variable.");
}
}
if (pthread_mutex_unlock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't unlock condition mutex.");
+ dmnsn_error("Couldn't unlock condition mutex.");
}
}
@@ -183,13 +178,13 @@ dmnsn_done_progress(dmnsn_progress *progress)
dmnsn_progress_unlock(progress);
if (pthread_mutex_lock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't lock condition mutex.");
+ dmnsn_error("Couldn't lock condition mutex.");
}
if (pthread_cond_broadcast(progress->cond) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't signal condition variable.");
+ dmnsn_error("Couldn't signal condition variable.");
}
if (pthread_mutex_unlock(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't unlock condition mutex.");
+ dmnsn_error("Couldn't unlock condition mutex.");
}
}
@@ -199,7 +194,7 @@ static void
dmnsn_progress_rdlock(const dmnsn_progress *progress)
{
if (pthread_rwlock_rdlock(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't acquire read-lock.");
+ dmnsn_error("Couldn't acquire read-lock.");
}
}
@@ -207,7 +202,7 @@ static void
dmnsn_progress_wrlock(dmnsn_progress *progress)
{
if (pthread_rwlock_wrlock(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't acquire write-lock.");
+ dmnsn_error("Couldn't acquire write-lock.");
}
}
@@ -215,6 +210,6 @@ static void
dmnsn_progress_unlock(const dmnsn_progress *progress)
{
if (pthread_rwlock_unlock(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't unlock read-write lock.");
+ dmnsn_error("Couldn't unlock read-write lock.");
}
}
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 4e762f3..9a3b323 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -43,7 +43,7 @@ dmnsn_raytrace_scene(dmnsn_scene *scene)
{
dmnsn_progress *progress = dmnsn_raytrace_scene_async(scene);
if (dmnsn_finish_progress(progress) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Error occured while raytracing.");
+ dmnsn_error("Error occured while raytracing.");
}
}
diff --git a/libdimension/threads.c b/libdimension/threads.c
index 35127ac..fc05ac7 100644
--- a/libdimension/threads.c
+++ b/libdimension/threads.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2010-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -68,7 +68,7 @@ dmnsn_new_thread(dmnsn_progress *progress, dmnsn_thread_fn *thread_fn,
payload->progress = progress;
if (pthread_create(&progress->thread, NULL, &dmnsn_thread, payload) != 0) {
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't start thread.");
+ dmnsn_error("Couldn't start thread.");
}
}
@@ -104,7 +104,7 @@ dmnsn_execute_concurrently(dmnsn_concurrent_thread_fn *thread_fn,
if (pthread_create(&threads[i], NULL, &dmnsn_concurrent_thread,
&payloads[i]) != 0)
{
- dmnsn_error(DMNSN_SEVERITY_HIGH, "Couldn't start worker thread.");
+ dmnsn_error("Couldn't start worker thread.");
}
}
@@ -115,8 +115,7 @@ dmnsn_execute_concurrently(dmnsn_concurrent_thread_fn *thread_fn,
ret = payloads[i].ret;
}
} else {
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't join worker thread.");
- ret = -1;
+ dmnsn_error("Couldn't join worker thread.");
}
}
diff --git a/tests/dimension/arithexp.sh b/tests/dimension/arithexp.sh
index c5be884..3f47020 100755
--- a/tests/dimension/arithexp.sh
+++ b/tests/dimension/arithexp.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-arithexp=$(${top_builddir}/dimension/dimension --parse ${srcdir}/arithexp.pov)
+arithexp=$(${top_builddir}/dimension/dimension --strict --parse ${srcdir}/arithexp.pov)
arithexp_exp="$(echo -n \
'((object
(sphere
diff --git a/tests/dimension/csg.sh b/tests/dimension/csg.sh
index 8a45a78..f282335 100755
--- a/tests/dimension/csg.sh
+++ b/tests/dimension/csg.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2010-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-csg=$(${top_builddir}/dimension/dimension -w768 -h480 --parse ${srcdir}/csg.pov)
+csg=$(${top_builddir}/dimension/dimension --strict -w768 -h480 --parse ${srcdir}/csg.pov)
csg_exp="$(echo -n \
'((camera
perspective
@@ -91,4 +91,4 @@ if [ "$csg" != "$csg_exp" ]; then
exit 1
fi
-${top_builddir}/dimension/dimension -w768 -h480 -o csg.png ${srcdir}/csg.pov
+${top_builddir}/dimension/dimension --strict -w768 -h480 -o csg.png ${srcdir}/csg.pov
diff --git a/tests/dimension/demo.sh b/tests/dimension/demo.sh
index 80d5ade..b80adec 100755
--- a/tests/dimension/demo.sh
+++ b/tests/dimension/demo.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-demo=$(${top_builddir}/dimension/dimension -w768 -h480 --parse ${srcdir}/demo.pov)
+demo=$(${top_builddir}/dimension/dimension --strict -w768 -h480 --parse ${srcdir}/demo.pov)
demo_exp=$(echo -n \
'((camera
perspective
@@ -214,4 +214,4 @@ if [ "$demo" != "$demo_exp" ]; then
exit 1
fi
-${top_builddir}/dimension/dimension -w768 -h480 -o demo.png ${srcdir}/demo.pov
+${top_builddir}/dimension/dimension --strict -w768 -h480 -o demo.png ${srcdir}/demo.pov
diff --git a/tests/dimension/directives.sh b/tests/dimension/directives.sh
index 3e0233c..079e3e1 100755
--- a/tests/dimension/directives.sh
+++ b/tests/dimension/directives.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-directives=$(${top_builddir}/dimension/dimension --tokenize --parse ${srcdir}/directives.pov)
+directives=$(${top_builddir}/dimension/dimension --strict --tokenize --parse ${srcdir}/directives.pov)
directives_exp="$(echo -n \
'(#version (float "3.6") ;
#debug (string "debug")
diff --git a/tests/dimension/integer-overflow.sh b/tests/dimension/integer-overflow.sh
index 737c0e2..cdb3685 100755
--- a/tests/dimension/integer-overflow.sh
+++ b/tests/dimension/integer-overflow.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-integer_overflow=$(${top_builddir}/dimension/dimension --parse ${srcdir}/integer-overflow.pov)
+integer_overflow=$(${top_builddir}/dimension/dimension --strict --parse ${srcdir}/integer-overflow.pov)
integer_overflow_exp="$(echo -n \
'((object
(torus
diff --git a/tests/dimension/invalid-macro.sh b/tests/dimension/invalid-macro.sh
index 30186fb..144cb21 100755
--- a/tests/dimension/invalid-macro.sh
+++ b/tests/dimension/invalid-macro.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,5 +19,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-${top_builddir}/dimension/dimension --parse ${srcdir}/invalid-macro.pov
+${top_builddir}/dimension/dimension --strict --parse ${srcdir}/invalid-macro.pov
[ $? -lt 128 -a $? -gt 0 ]
diff --git a/tests/dimension/labels.sh b/tests/dimension/labels.sh
index c6e99b1..83b2f05 100755
--- a/tests/dimension/labels.sh
+++ b/tests/dimension/labels.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-labels=$(${top_builddir}/dimension/dimension --tokenize ${srcdir}/labels.pov)
+labels=$(${top_builddir}/dimension/dimension --strict --tokenize ${srcdir}/labels.pov)
labels_exp='(camera { } sphere { color (identifier "new_identifier") } box { color (identifier "new_identifier") })';
if [ "$labels" != "$labels_exp" ]; then
diff --git a/tests/dimension/numeric.sh b/tests/dimension/numeric.sh
index 0f9c7ef..6baca70 100755
--- a/tests/dimension/numeric.sh
+++ b/tests/dimension/numeric.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-numeric=$(${top_builddir}/dimension/dimension --tokenize ${srcdir}/numeric.pov)
+numeric=$(${top_builddir}/dimension/dimension --strict --tokenize ${srcdir}/numeric.pov)
numeric_exp=$(echo -n \
'((integer "1")
(integer "123456789")
diff --git a/tests/dimension/punctuation.sh b/tests/dimension/punctuation.sh
index 339caef..2fde521 100755
--- a/tests/dimension/punctuation.sh
+++ b/tests/dimension/punctuation.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-punctuation=$(${top_builddir}/dimension/dimension --tokenize ${srcdir}/punctuation.pov)
+punctuation=$(${top_builddir}/dimension/dimension --strict --tokenize ${srcdir}/punctuation.pov)
punctuation_exp='({ } \( \) [ ] + - * / , ; ? : & . | = < > ! <= >= !=)'
if [ "$punctuation" != "$punctuation_exp" ]; then
diff --git a/tests/dimension/strings.sh b/tests/dimension/strings.sh
index f9a1cfd..2fee2c6 100755
--- a/tests/dimension/strings.sh
+++ b/tests/dimension/strings.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-strings=$(${top_builddir}/dimension/dimension --tokenize ${srcdir}/strings.pov)
+strings=$(${top_builddir}/dimension/dimension --strict --tokenize ${srcdir}/strings.pov)
strings_exp=$(/bin/echo -e "((string \"This is a string with escape sequences: \a\b\f\n\r\t!#\v\\\'\"\"))")
if [ "$strings" != "$strings_exp" ]; then
diff --git a/tests/dimension/tbuffer-overlap.sh b/tests/dimension/tbuffer-overlap.sh
index 8e5f52e..83a65d7 100755
--- a/tests/dimension/tbuffer-overlap.sh
+++ b/tests/dimension/tbuffer-overlap.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,5 +19,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-${top_builddir}/dimension/dimension --parse ${srcdir}/tbuffer-overlap.pov
+${top_builddir}/dimension/dimension --strict --parse ${srcdir}/tbuffer-overlap.pov
[ $? -lt 128 -a $? -gt 0 ]
diff --git a/tests/dimension/transformations.sh b/tests/dimension/transformations.sh
index 462dbeb..e53d9cf 100755
--- a/tests/dimension/transformations.sh
+++ b/tests/dimension/transformations.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#########################################################################
-# Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> #
+# Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> #
# #
# This file is part of The Dimension Test Suite. #
# #
@@ -19,7 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
-transformations=$(${top_builddir}/dimension/dimension --parse ${srcdir}/transformations.pov)
+transformations=$(${top_builddir}/dimension/dimension --strict --parse ${srcdir}/transformations.pov)
transformations_exp="$(echo -n \
'((object
(sphere
@@ -61,4 +61,4 @@ if [ "$transformations" != "$transformations_exp" ]; then
exit 1
fi
-${top_builddir}/dimension/dimension -w1 -h1 -o /dev/null ${srcdir}/transformations.pov
+${top_builddir}/dimension/dimension --strict -w1 -h1 -o /dev/null ${srcdir}/transformations.pov
diff --git a/tests/libdimension/Makefile.am b/tests/libdimension/Makefile.am
index 718056e..8a53bcf 100644
--- a/tests/libdimension/Makefile.am
+++ b/tests/libdimension/Makefile.am
@@ -20,8 +20,9 @@
INCLUDES = -I$(top_srcdir)/libdimension
check_LTLIBRARIES = libdimension-tests.la
-check_PROGRAMS = error-test \
- warning-test \
+check_PROGRAMS = warning-test \
+ warning-as-error-test \
+ error-test \
list-test \
polynomial-test \
prtree-test \
@@ -30,7 +31,7 @@ check_PROGRAMS = error-test \
render-test \
cxx-test
TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = error-test
+XFAIL_TESTS = warning-as-error-test error-test
if !PNG
XFAIL_TESTS += png-test
@@ -50,12 +51,15 @@ else
libdimension_tests_la_SOURCES += display-stubs.c
endif
-error_test_SOURCES = error.c
-error_test_LDADD = libdimension-tests.la
-
warning_test_SOURCES = warning.c
warning_test_LDADD = libdimension-tests.la
+warning_as_error_test_SOURCES = warning-as-error.c
+warning_as_error_test_LDADD = libdimension-tests.la
+
+error_test_SOURCES = error.c
+error_test_LDADD = libdimension-tests.la
+
list_test_SOURCES = list.c
list_test_LDADD = libdimension-tests.la
diff --git a/tests/libdimension/cxx.cpp b/tests/libdimension/cxx.cpp
index 0a4b44d..43517e1 100644
--- a/tests/libdimension/cxx.cpp
+++ b/tests/libdimension/cxx.cpp
@@ -26,6 +26,9 @@
int
main(void)
{
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
+
/* Make sure we can to bit-ops on this enum type */
dmnsn_quality quality = DMNSN_RENDER_PIGMENT | DMNSN_RENDER_LIGHTS;
diff --git a/tests/libdimension/error.c b/tests/libdimension/error.c
index e8100f0..3f25d0a 100644
--- a/tests/libdimension/error.c
+++ b/tests/libdimension/error.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -25,8 +25,6 @@
int
main(void)
{
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
- dmnsn_error(DMNSN_SEVERITY_LOW, "This error is expected.");
-
+ dmnsn_error("This error is expected.");
return EXIT_SUCCESS;
}
diff --git a/tests/libdimension/gl.c b/tests/libdimension/gl.c
index 581c380..662ae7b 100644
--- a/tests/libdimension/gl.c
+++ b/tests/libdimension/gl.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -23,8 +23,8 @@
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
/* Allocate our canvas */
dmnsn_canvas *canvas = dmnsn_new_canvas(768, 480);
diff --git a/tests/libdimension/list.c b/tests/libdimension/list.c
index d8760a1..8f8819e 100644
--- a/tests/libdimension/list.c
+++ b/tests/libdimension/list.c
@@ -40,8 +40,8 @@ dmnsn_comparator(const dmnsn_list_iterator *i, const dmnsn_list_iterator *j)
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
dmnsn_list *list = dmnsn_new_list(sizeof(dmnsn_item));
diff --git a/tests/libdimension/png.c b/tests/libdimension/png.c
index a3e4da8..33a3a67 100644
--- a/tests/libdimension/png.c
+++ b/tests/libdimension/png.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -24,8 +24,8 @@
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
/* Allocate our canvas */
dmnsn_canvas *canvas = dmnsn_new_canvas(768, 480);
diff --git a/tests/libdimension/polynomial.c b/tests/libdimension/polynomial.c
index cc643f6..238f92d 100644
--- a/tests/libdimension/polynomial.c
+++ b/tests/libdimension/polynomial.c
@@ -28,8 +28,8 @@
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
double poly[6], x[5];
/* poly[] = (x + 1)*(x - 1.2345)*(x - 2.3456)*(x - 5)*(x - 100) */
diff --git a/tests/libdimension/prtree.c b/tests/libdimension/prtree.c
index aa7315b..ab6b78c 100644
--- a/tests/libdimension/prtree.c
+++ b/tests/libdimension/prtree.c
@@ -58,8 +58,8 @@ dmnsn_randomize_bounding_box(dmnsn_object *object)
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
const size_t nobjects = 128;
dmnsn_scene *scene = dmnsn_new_scene();
diff --git a/tests/libdimension/render.c b/tests/libdimension/render.c
index 3d2bd41..9e57916 100644
--- a/tests/libdimension/render.c
+++ b/tests/libdimension/render.c
@@ -204,8 +204,8 @@ dmnsn_new_test_scene(void)
int
main(void)
{
- /* Set the resilience low for tests */
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
+ /* Treat warnings as errors for tests */
+ dmnsn_die_on_warnings(true);
/* Create the test scene */
dmnsn_scene *scene = dmnsn_new_test_scene();
diff --git a/tests/libdimension/warning-as-error.c b/tests/libdimension/warning-as-error.c
new file mode 100644
index 0000000..ce274d3
--- /dev/null
+++ b/tests/libdimension/warning-as-error.c
@@ -0,0 +1,31 @@
+/*************************************************************************
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
+ * *
+ * This file is part of The Dimension Test Suite. *
+ * *
+ * The Dimension Test Suite is free software; you can redistribute it *
+ * and/or modify it under the terms of the GNU General Public License as *
+ * published by the Free Software Foundation; either version 3 of the *
+ * License, or (at your option) any later version. *
+ * *
+ * The Dimension Test Suite is distributed in the hope that it will be *
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+/* Make sure warnings kill us in strict mode - this test should fail */
+
+#include "dimension.h"
+#include <stdlib.h>
+
+int
+main(void)
+{
+ dmnsn_die_on_warnings(true);
+ dmnsn_warning("This warning is expected.");
+ return EXIT_SUCCESS;
+}
diff --git a/tests/libdimension/warning.c b/tests/libdimension/warning.c
index 915c97a..593fe84 100644
--- a/tests/libdimension/warning.c
+++ b/tests/libdimension/warning.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2009-2011 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -25,33 +25,6 @@
int
main(void)
{
- if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) {
- fprintf(stderr, "--- Wrong default resilience! ---\n");
- return EXIT_FAILURE;
- }
-
- dmnsn_set_resilience(DMNSN_SEVERITY_LOW);
- if (dmnsn_get_resilience() != DMNSN_SEVERITY_LOW) {
- fprintf(stderr, "--- Resilience not updated! ---\n");
- return EXIT_FAILURE;
- }
-
- dmnsn_set_resilience(DMNSN_SEVERITY_MEDIUM);
- if (dmnsn_get_resilience() != DMNSN_SEVERITY_MEDIUM) {
- fprintf(stderr, "--- Resilience not updated! ---\n");
- return EXIT_FAILURE;
- }
-
- dmnsn_error(DMNSN_SEVERITY_LOW, "This warning is expected.");
-
- dmnsn_set_resilience(DMNSN_SEVERITY_HIGH);
- if (dmnsn_get_resilience() != DMNSN_SEVERITY_HIGH) {
- fprintf(stderr, "--- Resilience not updated! ---\n");
- return EXIT_FAILURE;
- }
-
- dmnsn_error(DMNSN_SEVERITY_LOW, "This warning is expected.");
- dmnsn_error(DMNSN_SEVERITY_MEDIUM, "This warning is expected.");
-
+ dmnsn_warning("This warning is expected.");
return EXIT_SUCCESS;
}