AC_HEADER_STDBOOL
AC_HEADER_SYS_WAIT
+AC_CHECK_TYPES(long long)
+
AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
AC_CHECK_HEADERS(termios.h)
int
cct_check_int_eq(const char *file, int line, const char *expression,
- int expected, int actual)
+ int64_t expected, int64_t actual)
{
if (expected == actual) {
cct_check_passed(file, line, expression);
return 1;
} else {
- char *exp_str = format("%i", expected);
- char *act_str = format("%i", actual);
- cct_check_failed(file, line, expression, exp_str, act_str);
- free(exp_str);
- free(act_str);
- return 0;
- }
-}
-
-int
-cct_check_uns_eq(const char *file, int line, const char *expression,
- unsigned expected, unsigned actual)
-{
- if (expected == actual) {
- cct_check_passed(file, line, expression);
- return 1;
- } else {
- char *exp_str = format("%i", expected);
- char *act_str = format("%i", actual);
+#ifdef HAVE_LONG_LONG
+ char *exp_str = format("%lld", (long long)expected);
+ char *act_str = format("%lld", (long long)actual);
+#else
+ char *exp_str = format("%ld", (long)expected);
+ char *act_str = format("%ld", (long)actual);
+#endif
cct_check_failed(file, line, expression, exp_str, act_str);
free(exp_str);
free(act_str);
#define CHECK_INT_EQ(expected, actual) \
do { \
- if (!cct_check_int_eq(__FILE__, __LINE__, #actual, (expected), (actual))) { \
- cct_test_end(); \
- cct_suite_end(); \
- return _test_counter; \
- } \
- } while (0)
-
-#define CHECK_UNS_EQ(expected, actual) \
- do { \
- if (!cct_check_uns_eq(__FILE__, __LINE__, #actual, (expected), (actual))) { \
+ if (!cct_check_int_eq(__FILE__, __LINE__, #actual, (expected), \
+ (actual))) { \
cct_test_end(); \
cct_suite_end(); \
return _test_counter; \
void cct_check_failed(const char *file, int line, const char *assertion,
const char *expected, const char *actual);
int cct_check_int_eq(const char *file, int line, const char *expression,
- int expected, int actual);
-int cct_check_uns_eq(const char *file, int line, const char *expression,
- unsigned expected, unsigned actual);
+ int64_t expected, int64_t actual);
int cct_check_str_eq(const char *file, int line, const char *expression,
const char *expected, const char *actual, int free1,
int free2);
create_file("foo.c", "");
CHECK(!cc_process_args(orig, &preprocessed, &compiler));
- CHECK_UNS_EQ(1, stats_get_pending(STATS_PREPROCESSING));
+ CHECK_INT_EQ(1, stats_get_pending(STATS_PREPROCESSING));
args_free(orig);
}
create_file("foo.c", "");
CHECK(!cc_process_args(orig, &preprocessed, &compiler));
- CHECK_UNS_EQ(1, stats_get_pending(STATS_UNSUPPORTED));
+ CHECK_INT_EQ(1, stats_get_pending(STATS_UNSUPPORTED));
args_free(orig);
}
CHECK_STR_EQ("", conf->base_dir);
CHECK_STR_EQ_FREE1(format("%s/.ccache", get_home_directory()),
conf->cache_dir);
- CHECK_UNS_EQ(2, conf->cache_dir_levels);
+ CHECK_INT_EQ(2, conf->cache_dir_levels);
CHECK_STR_EQ("", conf->compiler);
CHECK_STR_EQ("mtime", conf->compiler_check);
CHECK(!conf->compression);
CHECK(!conf->hard_link);
CHECK(!conf->hash_dir);
CHECK_STR_EQ("", conf->log_file);
- CHECK_UNS_EQ(0, conf->max_files);
- CHECK_UNS_EQ(1024*1024, conf->max_size);
+ CHECK_INT_EQ(0, conf->max_files);
+ CHECK_INT_EQ(1024*1024, conf->max_size);
CHECK_STR_EQ("", conf->path);
CHECK_STR_EQ("", conf->prefix_command);
CHECK(!conf->read_only);
CHECK(!conf->recache);
CHECK(!conf->run_second_cpp);
- CHECK_UNS_EQ(0, conf->sloppiness);
+ CHECK_INT_EQ(0, conf->sloppiness);
CHECK(conf->stats);
CHECK_STR_EQ("", conf->temporary_dir);
- CHECK_UNS_EQ(UINT_MAX, conf->umask);
+ CHECK_INT_EQ(UINT_MAX, conf->umask);
CHECK(!conf->unify);
conf_free(conf);
}
CHECK_STR_EQ_FREE1(format("/%s/foo/%s", user, user), conf->base_dir);
CHECK_STR_EQ_FREE1(format("%s$/%s/.ccache", user, user), conf->cache_dir);
- CHECK_UNS_EQ(4, conf->cache_dir_levels);
+ CHECK_INT_EQ(4, conf->cache_dir_levels);
CHECK_STR_EQ("foo", conf->compiler);
CHECK_STR_EQ("none", conf->compiler_check);
CHECK(conf->compression);
CHECK(conf->hard_link);
CHECK(conf->hash_dir);
CHECK_STR_EQ_FREE1(format("%s%s", user, user), conf->log_file);
- CHECK_UNS_EQ(17, conf->max_files);
- CHECK_UNS_EQ(123 * 1024, conf->max_size);
+ CHECK_INT_EQ(17, conf->max_files);
+ CHECK_INT_EQ(123 * 1024, conf->max_size);
CHECK_STR_EQ_FREE1(format("%s.x", user), conf->path);
CHECK_STR_EQ_FREE1(format("x%s", user), conf->prefix_command);
CHECK(conf->read_only);
CHECK(conf->recache);
CHECK(conf->run_second_cpp);
- CHECK_UNS_EQ(SLOPPY_INCLUDE_FILE_MTIME|SLOPPY_FILE_MACRO|SLOPPY_TIME_MACROS,
+ CHECK_INT_EQ(SLOPPY_INCLUDE_FILE_MTIME|SLOPPY_FILE_MACRO|SLOPPY_TIME_MACROS,
conf->sloppiness);
CHECK(!conf->stats);
CHECK_STR_EQ_FREE1(format("%s_foo", user), conf->temporary_dir);
- CHECK_UNS_EQ(0777, conf->umask);
+ CHECK_INT_EQ(0777, conf->umask);
CHECK(conf->unify);
conf_free(conf);
/*
- * Copyright (C) 2010 Joel Rosdahl
+ * Copyright (C) 2010-2011 Joel Rosdahl
*
* This program 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
{
struct counters *counters = counters_init(0);
- CHECK_UNS_EQ(0, counters->allocated);
- CHECK_UNS_EQ(0, counters->size);
+ CHECK_INT_EQ(0, counters->allocated);
+ CHECK_INT_EQ(0, counters->size);
counters_free(counters);
}
int i;
struct counters *counters = counters_init(7);
- CHECK_UNS_EQ(32, counters->allocated);
- CHECK_UNS_EQ(7, counters->size);
+ CHECK_INT_EQ(32, counters->allocated);
+ CHECK_INT_EQ(7, counters->size);
for (i = 0; i < 7; i++) {
- CHECK_UNS_EQ(0, counters->data[i]);
+ CHECK_INT_EQ(0, counters->data[i]);
}
counters_free(counters);
{
struct counters *counters = counters_init(0);
- CHECK_UNS_EQ(0, counters->allocated);
+ CHECK_INT_EQ(0, counters->allocated);
counters_resize(counters, 50);
- CHECK_UNS_EQ(50, counters->size);
- CHECK_UNS_EQ(96, counters->allocated);
+ CHECK_INT_EQ(50, counters->size);
+ CHECK_INT_EQ(96, counters->allocated);
counters_free(counters);
}
/*
- * Copyright (C) 2010 Joel Rosdahl
+ * Copyright (C) 2010-2011 Joel Rosdahl
*
* This program 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
fclose(f);
stats_read("stats", counters);
- CHECK_UNS_EQ(100, counters->size);
- CHECK_UNS_EQ(73, counters->data[73]);
+ CHECK_INT_EQ(100, counters->size);
+ CHECK_INT_EQ(73, counters->data[73]);
stats_write("stats", counters);
- CHECK_UNS_EQ(100, counters->size);
- CHECK_UNS_EQ(99, counters->data[99]);
+ CHECK_INT_EQ(100, counters->size);
+ CHECK_INT_EQ(99, counters->data[99]);
counters_free(counters);
}
{
size_t size;
CHECK(parse_size_with_suffix("0", &size));
- CHECK_UNS_EQ(0, size);
+ CHECK_INT_EQ(0, size);
CHECK(parse_size_with_suffix("42K", &size));
- CHECK_UNS_EQ(42, size);
+ CHECK_INT_EQ(42, size);
CHECK(parse_size_with_suffix("1.0M", &size));
- CHECK_UNS_EQ(1024, size);
+ CHECK_INT_EQ(1024, size);
CHECK(parse_size_with_suffix("1.1M", &size));
- CHECK_UNS_EQ(1.1 * 1024, size);
+ CHECK_INT_EQ(1.1 * 1024, size);
CHECK(parse_size_with_suffix("438.5M", &size));
- CHECK_UNS_EQ(438.5 * 1024, size);
+ CHECK_INT_EQ(438.5 * 1024, size);
CHECK(parse_size_with_suffix("1.0G", &size));
- CHECK_UNS_EQ(1024 * 1024, size);
+ CHECK_INT_EQ(1024 * 1024, size);
CHECK(parse_size_with_suffix("17.1G", &size));
- CHECK_UNS_EQ(17.1 * 1024 * 1024, size);
+ CHECK_INT_EQ(17.1 * 1024 * 1024, size);
}
TEST_SUITE_END