Skip to content

Commit

Permalink
[tests] try to address some test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed May 9, 2024
1 parent 74a01bb commit efb85ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/base/humanize.time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ point::as_time_ago() const
current_time.tv_sec = convert_log_time_to_local(current_time.tv_sec);
}

auto delta
= std::chrono::seconds(current_time.tv_sec - this->p_past_point.tv_sec);
auto curr_secs = std::chrono::seconds(current_time.tv_sec);
auto past_secs = std::chrono::seconds(this->p_past_point.tv_sec);
auto delta = curr_secs - past_secs;
if (delta < 0s) {
return "in the future";
}
Expand Down Expand Up @@ -113,8 +114,8 @@ point::as_precise_time_ago() const
return fmt::format(FMT_STRING("{:2} seconds ago"), diff.tv_sec);
}

time_t seconds = diff.tv_sec % 60;
time_t minutes = diff.tv_sec / 60;
lnav::time64_t seconds = diff.tv_sec % 60;
lnav::time64_t minutes = diff.tv_sec / 60;

return fmt::format(FMT_STRING("{:2} minute{} and {:2} second{} ago"),
minutes,
Expand Down
10 changes: 2 additions & 8 deletions src/lnav_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,12 @@ com_unix_time(exec_context& ec,
}
if (parsed) {
char ftime[128];
int len;

strftime(ftime,
sizeof(ftime),
"%a %b %d %H:%M:%S %Y %z %Z",
localtime_r(&u_time, &log_time));
len = strlen(ftime);
snprintf(ftime + len, sizeof(ftime) - len, " -- %ld", u_time);
retval = std::string(ftime);
retval = fmt::format(FMT_STRING("{} -- {}"), ftime, u_time);
} else {
return ec.make_error("invalid unix time -- {}", args[1]);
}
Expand Down Expand Up @@ -662,17 +659,14 @@ com_current_time(exec_context& ec,
struct tm localtm;
std::string retval;
time_t u_time;
size_t len;

memset(&localtm, 0, sizeof(localtm));
u_time = time(nullptr);
strftime(ftime,
sizeof(ftime),
"%a %b %d %H:%M:%S %Y %z %Z",
localtime_r(&u_time, &localtm));
len = strlen(ftime);
snprintf(ftime + len, sizeof(ftime) - len, " -- %ld", u_time);
retval = std::string(ftime);
retval = fmt::format(FMT_STRING("{} -- {}"), ftime, u_time);

return Ok(retval);
}
Expand Down
5 changes: 5 additions & 0 deletions src/third-party/rapidyaml/ryml_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ C4_FOR_EACH(PRN_STRUCT_OFFSETS, a, b, c);
#endif
#define C4_BYTE_ORDER _C4EL

#elif defined(mips) || defined(__mips__) || defined(__mips)

#define C4_WORDSIZE 8
#define C4_BYTE_ORDER _C4EL

#elif defined(__EMSCRIPTEN__)
# define C4_BYTE_ORDER _C4EL
# define C4_WORDSIZE 4
Expand Down
3 changes: 3 additions & 0 deletions test/test_cmds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ run_cap_test ${lnav_test} -n \
logfile_rollover.1.live

touch -t 200711030923 ${srcdir}/logfile_syslog.0
run_cap_test ${lnav_test} -n \
${test_dir}/logfile_syslog.0

run_cap_test ${lnav_test} -n \
-c ":switch-to-view histogram" \
-c ":zoom-to 4-hour" \
Expand Down

0 comments on commit efb85ed

Please sign in to comment.