tests: rename freq parameter to period_ms
PATCH 1/1 tests: rename freq parameter to period_ms
The freq field of struct gpiod_test_event_thread is actually used as a period measured in milliseconds, so rename it to period_ms in the struct and wherever it is used as a function parameter.
Signed-off-by Kent Gibson <[email protected]>
--- bindings/cxx/tests/gpio-mockup.cpp | 6 +++--- bindings/cxx/tests/gpio-mockup.hpp | 4 ++-- bindings/python/tests/gpiod_py_test.py | 6 +++--- tests/gpiod-test.c | 8 ++++---- tests/gpiod-test.h | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-)
bindings/cxx/tests/gpio-mockup.cpp +3 -3
@@ -116,10 +116,10 @@ mockup::probe_guard::~probe_guard(void) } mockup::event_thread::event_thread(unsigned int chip_index, - unsigned int line_offset, unsigned int freq) + unsigned int line_offset, unsigned int period_ms) : _m_chip_index(chip_index), _m_line_offset(line_offset), - _m_freq(freq), + _m_period_ms(period_ms), _m_stop(false), _m_mutex(), _m_cond(),
@@ -146,7 +146,7 @@ void mockup::event_thread::event_worker(void) break; ::std::cv_status status = this->_m_cond.wait_for(lock, - std::chrono::milliseconds(this->_m_freq)); + std::chrono::milliseconds(this->_m_period_ms)); if (status == ::std::cv_status::timeout) mockup::instance().chip_set_pull(this->_m_chip_index, this->_m_line_offset, i % 2);
bindings/cxx/tests/gpio-mockup.hpp +2 -2
@@ -61,7 +61,7 @@ public: { public: - event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int freq); + event_thread(unsigned int chip_index, unsigned int line_offset, unsigned int period_ms); ~event_thread(void); event_thread(const event_thread& other) = delete;
@@ -75,7 +75,7 @@ public: unsigned int _m_chip_index; unsigned int _m_line_offset; - unsigned int _m_freq; + unsigned int _m_period_ms; bool _m_stop;
bindings/python/tests/gpiod_py_test.py +3 -3
@@ -34,11 +34,11 @@ class MockupTestCase(unittest.TestCase): class EventThread(threading.Thread): - def __init__(self, chip_idx, line_offset, freq): + def __init__(self, chip_idx, line_offset, period_ms): threading.Thread.__init__(self) self.chip_idx = chip_idx self.line_offset = line_offset - self.freq = freq + self.period_ms = period_ms self.lock = threading.Lock() self.cond = threading.Condition(self.lock) self.should_stop = False
@@ -50,7 +50,7 @@ class EventThread(threading.Thread): if self.should_stop: break; - if not self.cond.wait(float(self.freq) / 1000): + if not self.cond.wait(float(self.period_ms) / 1000): mockup.chip_set_pull(self.chip_idx, self.line_offset, i % 2) i += 1
tests/gpiod-test.c +4 -4
@@ -29,7 +29,7 @@ struct gpiod_test_event_thread {gboolean should_stop;guint chip_index;guint line_offset; -guint freq; +guint period_ms; }; static struct {
@@ -202,7 +202,7 @@ static gpointer event_worker_func(gpointer data)break ; } - end_time =g_get_monotonic_time () + thread->freq *1000 ; + end_time =g_get_monotonic_time () + thread->period_ms *1000 ; signalled =g_cond_wait_until (&thread->cond, &thread->lock, end_time);
@@ -217,7 +217,7 @@ static gpointer event_worker_func(gpointer data) }GpiodTestEventThread * -gpiod_test_start_event_thread (guint chip_index,guint line_offset,guint freq) +gpiod_test_start_event_thread (guint chip_index,guint line_offset,guint period_ms) {GpiodTestEventThread *thread =g_malloc0 (sizeof (*thread));
@@ -226,7 +226,7 @@ gpiod_test_start_event_thread(guint chip_index, guint line_offset, guint freq) thread->chip_index = chip_index; thread->line_offset = line_offset; - thread->freq = freq; + thread->period_ms = period_ms; thread->id =g_thread_new ("event-worker" , event_worker_func, thread);
tests/gpiod-test.h +1 -1
@@ -96,7 +96,7 @@ typedef struct gpiod_test_event_thread GpiodTestEventThread;GpiodTestEventThread *gpiod_test_start_event_thread (guint chip_index, -guint line_offset,guint freq); +guint line_offset,guint period_ms);void gpiod_test_stop_event_thread (GpiodTestEventThread *thread); G_DEFINE_AUTOPTR_CLEANUP_FUNC(GpiodTestEventThread,
Signature · 1 line
2.28.0
Bartosz Golaszewski
AppliedQuoted 7 lines · Kent Gibson
The freq field of struct
gpiod_test_event_threadis actually used as a period measured in milliseconds, so rename it toperiod_msin the struct and wherever it is used as a function parameter.Signed-off-by Kent Gibson <[email protected]>---
Applied, thanks!
Bartosz