Douglas Henrique Koerich 84b5114027 Images of ptp-notification containers for Debian
This change reorganizes the source directories of the ptp-notification's
containers: locationservice; notificationservice; notificationclient, to
be reused by both CentOS and Debian Dockerfiles to build the images
having the corresponding OS-specific base, together with the new files
used to build images for Debian.

Tests:
PASS: Build images of the 3 containers for Debian
PASS: Upload and apply changed ptp-notification application to pull
      Debian images from private repository (since final tag is
      not possible yet) in a Debian AIO-SX environment

Regression:
PASS: Build images of the 3 containers for CentOS

Story: 2009831
Task: 45658
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
Change-Id: I4aa9650dbebe5ba68cd4d104ee0995e79681cfa4
2022-07-19 15:01:27 -03:00

57 lines
2.4 KiB
Python

#
# Copyright (c) 2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import unittest
import os
from unittest.mock import MagicMock
from trackingfunctionsdk.common.helpers.dmesg_watcher import DmesgWatcher
from trackingfunctionsdk.common.helpers.gnss_monitor import GnssMonitor
testpath = os.environ.get("TESTPATH", "")
class DmesgWatcherTests(unittest.TestCase):
testDmesgWatcher = DmesgWatcher()
observer_a = GnssMonitor(testpath + "./test_input_files/ts2phc_valid.conf",
"tty_GNSS_1800_0", "0000:18:00.0",
testpath + "./test_input_files/mock_cgu_output")
observer_b = GnssMonitor(testpath + "./test_input_files/ts2phc_valid.conf",
"tty_GNSS_1a00_0", "0000:1a:00.0",
testpath + "./test_input_files/mock_cgu_output")
def test_parse_dmesg_event(self):
self.testDmesgWatcher.attach(self.observer_a)
self.testDmesgWatcher.notify = MagicMock()
with open(testpath + "./test_input_files/mock_kern.log", 'r') as dmesg:
for line in dmesg:
self.testDmesgWatcher.parse_dmesg_event(line)
assert self.testDmesgWatcher.notify.called
# Test that notify is not called when there is no match
self.testDmesgWatcher.notify.reset_mock()
self.testDmesgWatcher.attach(self.observer_b)
with open(testpath + "./test_input_files/mock_kern.log", 'r') as dmesg:
for line in dmesg:
self.testDmesgWatcher.parse_dmesg_event(line)
assert self.testDmesgWatcher.notify.assert_not_called
def test_attach_detach(self):
self.testDmesgWatcher.attach(self.observer_a)
self.testDmesgWatcher.attach(self.observer_b)
self.assertEqual(len(self.testDmesgWatcher._observers), 2)
self.testDmesgWatcher.detach(self.observer_a)
self.testDmesgWatcher.detach(self.observer_b)
self.assertEqual(len(self.testDmesgWatcher._observers), 0)
def test_notify(self):
self.observer_a.update = MagicMock
self.testDmesgWatcher.notify(observer=self.observer_a,
matched_line="2022-06-03T19:50:05.959 controller-0 kernel: warning [ "
"4.635511] ice 0000:18:00.0: <DPLL1> state changed to: "
"locked_ho_ack, pin GNSS-1PPS")
assert self.observer_a.update.called