Skip to content

Commit

Permalink
[pipeline] Set CAP_SYS_TIME for settimeofday ok in syncd test (sonic-…
Browse files Browse the repository at this point in the history
…net#1068)

The fix sonic-net#1067 is not enough. If docker user is non-root, set capability CAP_SYS_TIME for settimeofday success in syncd test, then test_watchdog_timer_clock_rollback can be run.

Co-authored-by: junhuazhai <[email protected]>
  • Loading branch information
jimmyzhai and junhuazhai authored Jun 22, 2022
1 parent bc3487e commit bd47844
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ jobs:
displayName: "Install gcovr 5.0 with recursive fix"
- script: |
set -ex
# Add SYS_TIME capability for settimeofday ok in syncd test
sudo setcap "cap_sys_time=eip" syncd/.libs/tests
make check
gcovr --version
find SAI/meta -name "*.gc*" | xargs rm -vf
Expand Down
1 change: 1 addition & 0 deletions syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ syncd_request_shutdown_LDADD = libSyncdRequestShutdown.a $(top_srcdir)/lib/libSa

tests_SOURCES = tests.cpp
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDFLAGS = -Wl,-rpath,$(top_srcdir)/lib/.libs -Wl,-rpath,$(top_srcdir)/meta/.libs
tests_LDADD = libSyncd.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/lib/.libs -lsairedis \
-L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)

Expand Down
6 changes: 0 additions & 6 deletions syncd/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,6 @@ void test_watchdog_timer_clock_rollback()
{
SWSS_LOG_ENTER();

if (getuid() != 0)
{
SWSS_LOG_WARN("this test requires root for set time");
return;
}

const int64_t WARN_TIMESPAN_USEC = 30 * 1000000;
const uint8_t ROLLBACK_TIME_SEC = 5;
const uint8_t LONG_RUNNING_API_TIME_SEC = 3;
Expand Down

0 comments on commit bd47844

Please sign in to comment.