Beispiel #1
0
Test(data, types_identical_with_single_types) {
    struct type type1 = init_type(),
                type2 = init_type();
    
    type1.single = tid_integral;
    type2.single = tid_integral;
    cr_assert(types_identical(&type1, &type2));

    type1.single = tid_integral;
    type2.single = tid_real;
    cr_assert_not(types_identical(&type1, &type2));

    type1.single = tid_integral;
    cr_assert(types_identical(NULL, NULL));
    cr_assert_not(types_identical(&type1, NULL));
    cr_assert_not(types_identical(NULL, &type1));

    type1.single = tid_alpha;
    type2.single = tid_tuple;
    cr_assert(types_identical(&type1, &type2));
    type2.single = tid_real;
    cr_assert(types_identical(&type1, &type2));
    type2.single = tid_integral;
    cr_assert(types_identical(&type2, &type1));
    type2.single = tid_alpha;
    cr_assert(types_identical(&type1, &type2));
}
Beispiel #2
0
Test(test_pathutils, test_is_regular)
{
  int fd = open("test2.file", O_CREAT | O_RDWR, 0644);
  int error = close(fd);
  cr_assert_not(error, "close error");

  cr_assert(is_file_regular("test2.file"), "this is a regular file");
  cr_assert_not(is_file_regular("./"), "this is not a regular file");

  error = unlink("test2.file");
  cr_assert_not(error, "unlink error");
}
Beispiel #3
0
Test(test_pathutils, test_is_file_directory)
{
  int fd = open("test.file", O_CREAT | O_RDWR, 0644);
  cr_assert_not(fd < 0, "open error");
  ssize_t done = write(fd, "a", 1);
  cr_assert_eq(done, 1, "write error");
  int error = close(fd);
  cr_assert_not(error, "close error");

  cr_assert_not(is_file_directory("test.file"), "File is not a directory!");
  cr_assert(is_file_directory("./"), "File is a directory!");

  error = unlink("test.file");
  cr_assert_not(error, "unlink error");
}
Beispiel #4
0
void
assert_forget_negative(DNSCache *cache, gint cache_size)
{
  gint i;
  const gchar *hn = NULL;
  gsize hn_len;
  gboolean positive;
  gint positive_limit = cache_size / 2;

  for (i = 0; i < cache_size; i++)
    {
      guint32 ni = htonl(i);

      hn = NULL;
      positive = FALSE;
      if (i < positive_limit)
        {
          cr_assert(dns_cache_lookup(cache, AF_INET, (void *) &ni, &hn, &hn_len, &positive) || !positive,
                    "hmmm cache forgot positive entries too early, i=%d\n",
                    i);
        }
      else
        {
          cr_assert_not(dns_cache_lookup(cache, AF_INET, (void *) &ni, &hn, &hn_len, &positive) || positive,
                        "hmmm cache didn't forget negative entries in time, i=%d\n",
                        i);
        }
    }
}
static void
_test_empty_db(ContextInfoDB *context_info_db)
{
  cr_assert_not(context_info_db_is_loaded(context_info_db) == TRUE,
                "Empty ContextInfoDB should be in unloaded state.");
  cr_assert_not(context_info_db_is_indexed(context_info_db) == TRUE,
                "Empty ContextInfoDB should be in un-indexed state.");
  cr_assert_not(context_info_db_contains(context_info_db, "selector") == TRUE,
                "Method context_info_db_contains should work with empty ContextInfoDB.");
  cr_assert_eq(context_info_db_number_of_records(context_info_db, "selector"), 0,
               "Method context_info_db_number should work with empty ContextInfoDB.");
  int ctr = 0;
  context_info_db_foreach_record(context_info_db, "selector", _count_records,
                                 (gpointer) & ctr);
  cr_assert_eq(ctr, 0,
               "Method context_info_db_foreach_record should work for with empty ContextInfoDB.");
}
void
handle_new_entry(gpointer user_data)
{
  Journald *journald = user_data;
  journald_process(journald);
  cr_assert_not(poll_triggered, "%s", "Should called only once");
  poll_triggered = TRUE;
}
static void
assert_log_message_dropped(const gchar *input)
{
  LogParser *parser = create_parser(NULL);
  LogMessage *msg = copy_str_into_log_message(input);

  cr_assert_not(_process_log_message(parser, msg));

  log_msg_unref(msg);
  destroy_parser(parser);
}
Beispiel #8
0
Test(date, test_date_with_additional_text_at_the_end)
{
  const gchar *msg = "2015-01-26T16:14:49+0300 Disappointing log file";

  LogParser *parser = _construct_parser(NULL, NULL, LM_TS_STAMP);
  LogMessage *logmsg = _construct_logmsg(msg);
  gboolean success = log_parser_process(parser, &logmsg, NULL, log_msg_get_value(logmsg, LM_V_MESSAGE, NULL), -1);

  cr_assert_not(success, "successfully parsed but expected failure, msg=%s", msg);

  log_pipe_unref(&parser->super);
  log_msg_unref(logmsg);
}
Beispiel #9
0
Test(msg_ack, clone_ack)
{
  AckRecord *t = ack_record_new();
  t->init(t);

  LogMessage *cloned = create_clone(t->original, &t->path_options);

  log_msg_drop(cloned, &t->path_options, AT_PROCESSED);
  cr_assert_not(t->acked);

  t->deinit(t);
  cr_assert(t->acked);
  ack_record_free(t);
}
Beispiel #10
0
Test(test_run_id, is_same_run__differs_when_not_same_run)
{
  PersistState *state;

  state = create_persist_state("test_run_id__is_same_run__differs_when_not_same_run");

  run_id_init(state);
  int prev_run_id = run_id_get();

  state = restart_persist_state(state);

  run_id_init(state);

  cr_assert_not(run_id_is_same_run(prev_run_id), "Run_id_is_same_run returned true when the run differs");

  destroy_persist_state(state);
};
Beispiel #11
0
void
assert_forget_all(DNSCache *cache, gint cache_size)
{
  gint i;
  const gchar *hn = NULL;
  gsize hn_len;
  gboolean positive;

  for (i = 0; i < cache_size; i++)
    {
      guint32 ni = htonl(i);

      hn = NULL;
      positive = FALSE;
      cr_assert_not(dns_cache_lookup(cache, AF_INET, (void *) &ni, &hn, &hn_len, &positive),
                    "hmmm cache did not forget an expired entry, i=%d\n",
                    i);
    }
}