src/tests/deduplicate_test \
src/tests/pid_limiter \
src/tests/qos_distributions \
- src/tests/filters
+ src/tests/filters \
+ src/tests/libdlogutil_neg \
+ src/tests/libdlogutil_pos
check_CFLAGS = $(AM_CFLAGS) -O0 -fprofile-arcs -DUNIT_TEST \
-DEXIT_SKIP=77 -DEXIT_HARD_ERROR=99 # autotools convention exit codes
src_tests_hash_test_CFLAGS = $(check_CFLAGS)
src_tests_hash_test_LDFLAGS = $(AM_LDFLAGS)
+src_tests_libdlogutil_neg_SOURCES = src/tests/libdlogutil_neg.c \
+ src/libdlogutil/lib.c \
+ src/shared/queued_entry_timestamp.c \
+ src/shared/logprint.c \
+ src/shared/ptrs_list.c \
+ src/libdlogutil/logretrieve.c \
+ src/shared/logcommon.c \
+ src/libdlogutil/fd_info.c \
+ src/libdlogutil/sort_vector.c \
+ src/shared/logconfig.c \
+ src/shared/parsers.c \
+ src/libdlogutil/fdi_pipe.c \
+ src/libdlogutil/fdi_logger.c \
+ src/shared/backend_androidlogger.c \
+ src/shared/queued_entry.c \
+ src/shared/translate_syslog.c
+src_tests_libdlogutil_neg_CFLAGS = $(check_CFLAGS) -DLIBDLOGUTIL_BUILD
+# Use LIBDLOGUTIL_BUILD because we're checking this from a client application PoV, not internal
+src_tests_libdlogutil_neg_LDFLAGS = $(AM_LDFLAGS)
+
+
+src_tests_libdlogutil_pos_SOURCES = src/tests/libdlogutil_pos.c \
+ src/libdlogutil/lib.c \
+ src/shared/queued_entry_timestamp.c \
+ src/shared/logprint.c \
+ src/shared/ptrs_list.c \
+ src/libdlogutil/logretrieve.c \
+ src/shared/logcommon.c \
+ src/libdlogutil/fd_info.c \
+ src/libdlogutil/sort_vector.c \
+ src/shared/logconfig.c \
+ src/shared/parsers.c \
+ src/libdlogutil/fdi_pipe.c \
+ src/libdlogutil/fdi_logger.c \
+ src/shared/backend_androidlogger.c \
+ src/shared/queued_entry.c \
+ src/shared/translate_syslog.c
+src_tests_libdlogutil_pos_CFLAGS = $(check_CFLAGS) -DLIBDLOGUTIL_BUILD
+# Use LIBDLOGUTIL_BUILD because we're checking this from a client application PoV, not internal
+src_tests_libdlogutil_pos_LDFLAGS = $(AM_LDFLAGS)
+
src_tests_metrics_SOURCES = src/tests/metrics.c \
src/shared/metrics.c \
src/shared/hash.c
--- /dev/null
+#include "../include/dlogutil.h"
+#include <stdlib.h>
+#include <assert.h>
+#include <logcommon.h>
+#include <dlog_ioctl.h>
+#include "../libdlogutil/logretrieve.h"
+
+void negative_main(void)
+{
+ void *bad_ptr = (void *)0xFA1L;
+
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(NULL, LOG_ID_MAIN));
+
+ dlogutil_config_s *c = dlogutil_config_create();
+ assert(c);
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, LOG_ID_INVALID));
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, LOG_ID_MAX));
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, (log_id_t) -1));
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, (log_id_t) 98));
+
+ dlogutil_state_s *s;
+ assert(TIZEN_ERROR_NONE == dlogutil_config_mode_set_continuous(c));
+
+ assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_connect(c, &s)); // empty set
+
+ assert(TIZEN_ERROR_NONE == dlogutil_config_buffer_add(c, LOG_ID_MAIN));
+ assert(TIZEN_ERROR_NONE == dlogutil_config_buffer_add(c, LOG_ID_KMSG));
+ assert(TIZEN_ERROR_NOT_SUPPORTED == dlogutil_config_connect(c, &s)); // incompatible pair
+
+ // Invalid single buffer
+ const log_id_t invalid_ids[] =
+ { LOG_ID_INVALID
+ , LOG_ID_INVALID - 1
+ , LOG_ID_MAX
+ , LOG_ID_MAX + 1
+ , (log_id_t) -17
+ , (log_id_t) 42
+ };
+ for (size_t i = 0; i < NELEMS(invalid_ids); ++i) {
+ const log_id_t id = invalid_ids[i];
+ assert(dlogutil_buffer_get_name(id, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_default_ts_type(id, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_check_ts_type_available(id, DLOGUTIL_SORT_SENT_MONO, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ }
+
+ // Retrieval of data from NULL
+ assert(dlogutil_entry_get_tid(NULL, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_pid(NULL, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_priority(NULL, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_timestamp(NULL, DLOGUTIL_SORT_RECV_MONO, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_tag(NULL, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_message(NULL, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_alias(NULL, LOG_ID_MAIN, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+
+ // Retrieval of data into NULL
+ assert(dlogutil_entry_get_tid(bad_ptr, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_pid(bad_ptr, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_priority(bad_ptr, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_timestamp(bad_ptr, DLOGUTIL_SORT_RECV_MONO, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_tag(bad_ptr, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_entry_get_message(bad_ptr, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_name(LOG_ID_MAIN, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_default_ts_type(LOG_ID_MAIN, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_check_ts_type_available(LOG_ID_MAIN, DLOGUTIL_SORT_RECV_MONO, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_MAIN, NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+
+ // Wrong timestamp
+ assert(dlogutil_entry_get_timestamp(bad_ptr, 1337, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+
+ // NULL options
+ assert(dlogutil_config_filter_tid(NULL, 0) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_filter_pid(NULL, 0) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_filter_filterspec(NULL, "TIZEN") ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_sorting_disable(NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_sorting_enable(NULL) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_sorting_enable_with_size(NULL, 7) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_config_order_set(NULL, DLOGUTIL_SORT_RECV_MONO) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+
+ // Invalid buffer
+ assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_INVALID, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_MAX, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_alias(bad_ptr, (log_id_t) -1, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+ assert(dlogutil_buffer_get_alias(bad_ptr, (log_id_t) 99, bad_ptr) ==
+ TIZEN_ERROR_INVALID_PARAMETER);
+
+ // Destroying a NULL - no error, but doesn't crash either
+ dlogutil_config_destroy(NULL);
+
+ // Actual cleanup
+ dlogutil_config_destroy(c);
+}
+
+
+int main(int argc, char **argv)
+{
+ negative_main();
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+#include <stdlib.h>
+#include <assert.h>
+#include <logcommon.h>
+
+void positive_main(void)
+{
+ dlogutil_config_s *config = dlogutil_config_create();
+ assert(config);
+ assert(dlogutil_config_buffer_add(config, LOG_ID_MAIN) == 0);
+
+ dlogutil_config_destroy(config);
+}
+
+
+int main(int argc, char **argv)
+{
+ positive_main();
+ return 0;
+}
\ No newline at end of file
void *bad_ptr = (void *)0xFA1l;
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(NULL, LOG_ID_MAIN));
-
- dlogutil_config_s *c = dlogutil_config_create();
- assert(c);
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, LOG_ID_INVALID));
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, LOG_ID_MAX));
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, (log_id_t) -1));
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_buffer_add(c, (log_id_t) 98));
-
- dlogutil_state_s *s;
- assert(TIZEN_ERROR_NONE == dlogutil_config_mode_set_continuous(c));
-
- assert(TIZEN_ERROR_INVALID_PARAMETER == dlogutil_config_connect(c, &s)); // empty set
-
- assert(TIZEN_ERROR_NONE == dlogutil_config_buffer_add(c, LOG_ID_MAIN));
- assert(TIZEN_ERROR_NONE == dlogutil_config_buffer_add(c, LOG_ID_KMSG));
- assert(TIZEN_ERROR_NOT_SUPPORTED == dlogutil_config_connect(c, &s)); // incompatible pair
-
// Invalid single buffer
const log_id_t invalid_ids[] =
{ LOG_ID_INVALID
TIZEN_ERROR_INVALID_PARAMETER);
assert(dlogutil_buffer_get_usage(state, id, bad_ptr) ==
TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_name(id, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_default_ts_type(id, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_check_ts_type_available(id, DLOGUTIL_SORT_SENT_MONO, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
}
- // Retrieval of data from NULL
- assert(dlogutil_entry_get_tid(NULL, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_pid(NULL, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_priority(NULL, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_timestamp(NULL, DLOGUTIL_SORT_RECV_MONO, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_tag(NULL, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_message(NULL, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_alias(NULL, LOG_ID_MAIN, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
-
// Retrieval of data into NULL
- assert(dlogutil_entry_get_tid(bad_ptr, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_pid(bad_ptr, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_priority(bad_ptr, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_timestamp(bad_ptr, DLOGUTIL_SORT_RECV_MONO, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_tag(bad_ptr, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_entry_get_message(bad_ptr, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_name(LOG_ID_MAIN, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
assert(dlogutil_buffer_get_capacity(state, LOG_ID_MAIN, NULL) ==
TIZEN_ERROR_INVALID_PARAMETER);
assert(dlogutil_buffer_get_usage(state, LOG_ID_MAIN, NULL) ==
TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_default_ts_type(LOG_ID_MAIN, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_check_ts_type_available(LOG_ID_MAIN, DLOGUTIL_SORT_RECV_MONO, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_MAIN, NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
-
- // Wrong timestamp
- assert(dlogutil_entry_get_timestamp(bad_ptr, 1337, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
-
- // NULL options
- assert(dlogutil_config_filter_tid(NULL, 0) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_filter_pid(NULL, 0) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_filter_filterspec(NULL, "TIZEN") ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_sorting_disable(NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_sorting_enable(NULL) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_sorting_enable_with_size(NULL, 7) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_config_order_set(NULL, DLOGUTIL_SORT_RECV_MONO) ==
- TIZEN_ERROR_INVALID_PARAMETER);
-
- // Invalid buffer
- assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_INVALID, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_alias(bad_ptr, LOG_ID_MAX, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_alias(bad_ptr, (log_id_t) -1, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
- assert(dlogutil_buffer_get_alias(bad_ptr, (log_id_t) 99, bad_ptr) ==
- TIZEN_ERROR_INVALID_PARAMETER);
-
- // Destroying a NULL - no error, but doesn't crash either
- dlogutil_config_destroy(NULL);
-
// Actual cleanup
- dlogutil_config_destroy(c);
dlogutil_state_destroy(state);
}
}
return EXIT_SUCCESS;
-}
+}
\ No newline at end of file