Commit aff6b28c authored by Geoff Simmons's avatar Geoff Simmons

get rid of an obsolete function in format.c

parent e3d2d69a
......@@ -184,25 +184,6 @@ get_rec_fld(logline_t *rec, int n)
return get_fld(get_payload(rec), n);
}
double
get_tm(tx_t *tx)
{
char *ts, *epochstr;
double epocht = 0;
CHECK_OBJ_NOTNULL(tx, TX_MAGIC);
ts = get_hdr(tx, SLT_Timestamp, "Start");
if (ts != NULL && (epochstr = get_fld(ts, 0)) != NULL) {
char *p;
epocht = strtod(epochstr, &p);
}
if (epocht == 0)
epocht = tx->t;
return epocht;
}
static inline void
format(tx_t *tx, enum VSL_tag_e tag, char **s, size_t *len)
{
......
......@@ -42,7 +42,6 @@ logline_t *get_tag(tx_t *tx, enum VSL_tag_e tag);
char *get_hdr(tx_t *tx, enum VSL_tag_e tag, const char *hdr);
char *get_fld(const char *str, int n);
char *get_rec_fld(logline_t *rec, int n);
double get_tm(tx_t *tx);
formatter_f format_b_client;
formatter_f format_b_backend;
......
......@@ -338,56 +338,6 @@ static const char
return NULL;
}
static const char
*test_format_get_tm(void)
{
#define T1 "Start: 1427743146.529143 0.000000 0.000000"
#define TIME 1427743146.529306
#define TX_TIME 1427744284.563984
tx_t tx;
logline_t recs[NRECORDS];
chunk_t c[NRECORDS];
double tm;
printf("... testing get_tm()\n");
tx.magic = TX_MAGIC;
tx.t = TX_TIME;
VSTAILQ_INIT(&tx.lines);
for (int i = 0; i < NRECORDS; i++) {
recs[i].magic = LOGLINE_MAGIC;
recs[i].tag = SLT_ReqHeader;
recs[i].len = strlen("Bar: baz");
VSTAILQ_INSERT_TAIL(&tx.lines, &recs[i], linelist);
VSTAILQ_INIT(&recs[i].chunks);
c[i].magic = CHUNK_MAGIC;
c[i].data = (char *) calloc(1, config.chunk_size);
strcpy(c[i].data, "Bar: baz");
VSTAILQ_INSERT_TAIL(&recs[i].chunks, &c[i], chunklist);
}
recs[NRECORDS / 2].tag = SLT_Timestamp;
recs[NRECORDS / 2].len = strlen(T1);
strcpy(c[NRECORDS / 2].data, T1);
recs[NRECORDS - 1].tag = SLT_Timestamp;
sprintf(c[NRECORDS - 1].data, "Start: %.6f 0.000000 0.000000", TIME);
recs[NRECORDS - 1].len = strlen(c[NRECORDS - 1].data);
tm = get_tm(&tx);
MASSERT(fabs(tm - TIME) < 1e-6);
/* Start timestamp not found, use the tx timestamp */
recs[NRECORDS / 2].tag = SLT_ReqHeader;
recs[NRECORDS - 1].tag = SLT_ReqHeader;
tm = get_tm(&tx);
MASSERT(fabs(tm - TX_TIME) < 1e-6);
/* Empty line list */
VSTAILQ_INIT(&tx.lines);
tm = get_tm(&tx);
MASSERT(fabs(tm - TX_TIME) < 1e-6);
return NULL;
}
static const char
*test_format_H(void)
{
......@@ -808,6 +758,7 @@ static const char
init_tx_rec_chunk(&tx, &rec, &chunk);
MAN(chunk.data);
#define T1 "Start: 1427743146.529143 0.000000 0.000000"
set_record_data(&rec, &chunk, T1, SLT_Timestamp);
tm = localtime(&t);
MAN(strftime(strftime_s, config.max_reclen, fmt, tm));
......@@ -1271,7 +1222,6 @@ static const char
mu_run_test(test_format_get_hdr);
mu_run_test(test_format_get_fld);
mu_run_test(test_format_get_rec_fld);
mu_run_test(test_format_get_tm);
mu_run_test(test_format_b);
mu_run_test(test_format_D);
mu_run_test(test_format_H);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment