struct tm tm;
time_t after;
time_t actual;
- const double lower = -1;
+ struct timeval tv;
- after = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ after = tv.tv_sec;
/*
* Convert the ISO 8601 timestamp into a time_t
/*
* The timestamp should be before <= actual <= after
- * Note: as the microsecond portion of the time is truncated we use
- * a -1 as the lower bound for the time difference instead of
- * zero
*/
- assert_true(difftime(actual, before) >= lower);
- assert_true(difftime(after, actual) >= lower);
+ assert_true(difftime(actual, before) >= 0);
+ assert_true(difftime(after, actual) >= 0);
}
static void test_has_password_changed(void **state)
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_SUCCESS;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = operation_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *f = NULL;
json_t *g = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_ERR_OPERATIONS_ERROR;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = operation_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *f = NULL;
json_t *g = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_ERR_OPERATIONS_ERROR;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = operation_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_SUCCESS;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = password_change_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_SUCCESS;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = password_change_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
GUID_from_string(GUID, &guid);
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = transaction_json("delete", &guid, 10000099);
assert_int_equal(3, json_object_size(json.root));
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
GUID_from_string(GUID, &guid);
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = commit_failure_json(
"prepare",
987876,
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_SUCCESS;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = replicated_update_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
reply = talloc_zero(ctx, struct ldb_reply);
reply->error = LDB_ERR_NO_SUCH_OBJECT;
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = replicated_update_json(module, req, reply);
assert_int_equal(3, json_object_size(json.root));
struct tm tm;
time_t after;
time_t actual;
+ struct timeval tv;
- after = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ after = tv.tv_sec;
/*
* Convert the ISO 8601 timestamp into a time_t
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
req->operation = LDB_ADD;
add_transaction_id(req, TRANSACTION);
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = audit_group_json(module,
req,
"the-action",
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
req->operation = LDB_ADD;
add_transaction_id(req, TRANSACTION);
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = audit_group_json(module,
req,
"the-action",
json_t *v = NULL;
json_t *o = NULL;
time_t before;
+ struct timeval tv;
+ int rc;
TALLOC_CTX *ctx = talloc_new(NULL);
req->operation = LDB_ADD;
add_transaction_id(req, TRANSACTION);
- before = time(NULL);
+ rc = gettimeofday(&tv, NULL);
+ assert_return_code(rc, errno);
+ before = tv.tv_sec;
json = audit_group_json(module,
req,
"the-action",