Files
Robert Schmidt 8107939f08 Change OAI license to CSSL v1.0 (and others)
- all RAN code, CI code, configuration files, dockerfiles, in CSSL v1.0
- all deployment code (openshift, charts, ancillary files like shell
  scripts), in MIT
- documentation in CC-BY-4.0
- exceptions might apply and are listed in NOTICE
- there is a new LICENSES folder with all licenses
- CONTRIBUTIONS.md has been updated accordingly

For automated changes based on OAI PL v1.1:

    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.{c,h,cpp}
    perl -i~ -0pe 's/\/\*.*Licensed to the OpenAirInterface.*openairinterface.org\n#?/\/*\n * SPDX-License-Identifier: LicenseRef-CSSL-1.0\n/s' **/*.ts
    perl -i~ -0pe 's/<!--.*Licensed to the OpenAirInterface.*openairinterface.org\n.*-->/<!-- SPDX-License-Identifier: LicenseRef-CSSL-1.0 -->/s' **/*.xml

The rest (cmake, files with missing license, cmake) manually.
2026-03-27 16:36:37 +01:00

108 lines
4.6 KiB
Python

# SPDX-License-Identifier: LicenseRef-CSSL-1.0
import sys
import logging
logging.basicConfig(
level=logging.DEBUG,
stream=sys.stdout,
format="[%(asctime)s] %(levelname)8s: %(message)s"
)
import os
import unittest
sys.path.append('./') # to find OAI imports below
import cls_cmd
class TestCmd(unittest.TestCase):
def test_local_cmd(self):
with cls_cmd.getConnection("localhost") as cmd:
self.assertTrue(isinstance(cmd, cls_cmd.LocalCmd))
with cls_cmd.getConnection("None") as cmd:
self.assertTrue(isinstance(cmd, cls_cmd.LocalCmd))
with cls_cmd.getConnection("none") as cmd:
self.assertTrue(isinstance(cmd, cls_cmd.LocalCmd))
with cls_cmd.getConnection(None) as cmd:
self.assertTrue(isinstance(cmd, cls_cmd.LocalCmd))
ret = cmd.run("true")
self.assertEqual(ret.args, "true")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "")
ret = cmd.run("false")
self.assertEqual(ret.args, "false")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "")
ret = cmd.run("echo test")
self.assertEqual(ret.args, "echo test")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "test")
def test_local_script(self):
with cls_cmd.getConnection("localhost") as ssh:
ret = ssh.exec_script("tests/scripts/hello-world.sh", 1)
self.assertEqual(ret.args, "tests/scripts/hello-world.sh")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "+ echo hello, world\nhello, world")
with cls_cmd.getConnection("localhost") as ssh:
ret = ssh.exec_script("tests/scripts/hello-fail.sh", 1, "TESTFAIL")
self.assertEqual(ret.args, "tests/scripts/hello-fail.sh TESTFAIL")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "TESTFAIL")
with cls_cmd.getConnection("localhost") as ssh:
ret = ssh.exec_script("tests/scripts/hello-fail.sh", 1, "TESTFAIL2", "/tmp/result")
self.assertEqual(ret.args, "tests/scripts/hello-fail.sh TESTFAIL2 &> /tmp/result")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "")
with cls_cmd.getConnection("localhost") as ssh:
ret = ssh.run("cat /tmp/result")
self.assertEqual(ret.args, "cat /tmp/result")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "TESTFAIL2")
@unittest.skip("need to be able to passwordlessly SSH to localhost, also disable stty -ixon")
def test_remote_cmd(self):
with cls_cmd.getConnection("127.0.0.1") as cmd:
self.assertTrue(isinstance(cmd, cls_cmd.RemoteCmd))
ret = cmd.run("true")
self.assertEqual(ret.args, "true")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "")
ret = cmd.run("false")
self.assertEqual(ret.args, "false")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "")
ret = cmd.run("echo test")
self.assertEqual(ret.args, "echo test")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "test")
@unittest.skip("need to be able to passwordlessly SSH to localhost, also disable stty -ixon")
def test_remote_script(self):
with cls_cmd.getConnection("127.0.0.1") as ssh:
ret = ssh.exec_script("tests/scripts/hello-world.sh", 1)
self.assertEqual(ret.args, "tests/scripts/hello-world.sh")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "+ echo hello, world\nhello, world")
with cls_cmd.getConnection("127.0.0.1") as ssh:
ret = ssh.exec_script("tests/scripts/hello-fail.sh", 1, "TESTFAIL")
self.assertEqual(ret.args, "tests/scripts/hello-fail.sh TESTFAIL")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "TESTFAIL")
with cls_cmd.getConnection("127.0.0.1") as ssh:
ret = ssh.exec_script("tests/scripts/hello-fail.sh", 1, "TESTFAIL2", "/tmp/result")
self.assertEqual(ret.args, "tests/scripts/hello-fail.sh TESTFAIL2 &> /tmp/result")
self.assertEqual(ret.returncode, 1)
self.assertEqual(ret.stdout, "")
with cls_cmd.getConnection("localhost") as ssh:
ret = ssh.run("cat /tmp/result")
self.assertEqual(ret.args, "cat /tmp/result")
self.assertEqual(ret.returncode, 0)
self.assertEqual(ret.stdout, "TESTFAIL2")
if __name__ == '__main__':
unittest.main()