diff options
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/oescripts.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py index 7770b66a26..c169885cf3 100644 --- a/meta/lib/oeqa/selftest/cases/oescripts.py +++ b/meta/lib/oeqa/selftest/cases/oescripts.py | |||
| @@ -3,10 +3,12 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | import os | 5 | import os |
| 6 | import shutil | ||
| 6 | import unittest | 7 | import unittest |
| 7 | from oeqa.selftest.case import OESelftestTestCase | 8 | from oeqa.selftest.case import OESelftestTestCase |
| 8 | from oeqa.selftest.cases.buildhistory import BuildhistoryBase | 9 | from oeqa.selftest.cases.buildhistory import BuildhistoryBase |
| 9 | from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer | 10 | from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer |
| 11 | from oeqa.utils import CommandError | ||
| 10 | 12 | ||
| 11 | class BuildhistoryDiffTests(BuildhistoryBase): | 13 | class BuildhistoryDiffTests(BuildhistoryBase): |
| 12 | 14 | ||
| @@ -63,3 +65,59 @@ class OEPybootchartguyTests(OEScriptTests): | |||
| 63 | runCmd('%s/pybootchartgui/pybootchartgui.py %s -o %s/charts -f pdf' % (self.scripts_dir, self.buildstats, self.tmpdir)) | 65 | runCmd('%s/pybootchartgui/pybootchartgui.py %s -o %s/charts -f pdf' % (self.scripts_dir, self.buildstats, self.tmpdir)) |
| 64 | self.assertTrue(os.path.exists(self.tmpdir + "/charts.pdf")) | 66 | self.assertTrue(os.path.exists(self.tmpdir + "/charts.pdf")) |
| 65 | 67 | ||
| 68 | class OEGitproxyTests(OESelftestTestCase): | ||
| 69 | |||
| 70 | scripts_dir = os.path.join(get_bb_var('COREBASE'), 'scripts') | ||
| 71 | |||
| 72 | def test_oegitproxy_help(self): | ||
| 73 | try: | ||
| 74 | res = runCmd('%s/oe-git-proxy --help' % self.scripts_dir, assert_error=False) | ||
| 75 | self.assertTrue(False) | ||
| 76 | except CommandError as e: | ||
| 77 | self.assertEqual(2, e.retcode) | ||
| 78 | |||
| 79 | def run_oegitproxy(self, custom_shell=None): | ||
| 80 | os.environ['SOCAT'] = shutil.which("echo") | ||
| 81 | os.environ['ALL_PROXY'] = "https://proxy.example.com:3128" | ||
| 82 | os.environ['NO_PROXY'] = "*.example.com,.no-proxy.org,192.168.42.0/24,127.*.*.*" | ||
| 83 | |||
| 84 | if custom_shell is None: | ||
| 85 | prefix = '' | ||
| 86 | else: | ||
| 87 | prefix = custom_shell + ' ' | ||
| 88 | |||
| 89 | # outside, use the proxy | ||
| 90 | res = runCmd('%s%s/oe-git-proxy host.outside-example.com 9418' % | ||
| 91 | (prefix,self.scripts_dir)) | ||
| 92 | self.assertIn('PROXY:', res.output) | ||
| 93 | # match with wildcard suffix | ||
| 94 | res = runCmd('%s%s/oe-git-proxy host.example.com 9418' % | ||
| 95 | (prefix, self.scripts_dir)) | ||
| 96 | self.assertIn('TCP:', res.output) | ||
| 97 | # match just suffix | ||
| 98 | res = runCmd('%s%s/oe-git-proxy host.no-proxy.org 9418' % | ||
| 99 | (prefix, self.scripts_dir)) | ||
| 100 | self.assertIn('TCP:', res.output) | ||
| 101 | # match IP subnet | ||
| 102 | res = runCmd('%s%s/oe-git-proxy 192.168.42.42 9418' % | ||
| 103 | (prefix, self.scripts_dir)) | ||
| 104 | self.assertIn('TCP:', res.output) | ||
| 105 | # match IP wildcard | ||
| 106 | res = runCmd('%s%s/oe-git-proxy 127.1.2.3 9418' % | ||
| 107 | (prefix, self.scripts_dir)) | ||
| 108 | self.assertIn('TCP:', res.output) | ||
| 109 | |||
| 110 | # test that * globbering is off | ||
| 111 | os.environ['NO_PROXY'] = "*" | ||
| 112 | res = runCmd('%s%s/oe-git-proxy host.example.com 9418' % | ||
| 113 | (prefix, self.scripts_dir)) | ||
| 114 | self.assertIn('TCP:', res.output) | ||
| 115 | |||
| 116 | def test_oegitproxy_proxy(self): | ||
| 117 | self.run_oegitproxy() | ||
| 118 | |||
| 119 | def test_oegitproxy_proxy_dash(self): | ||
| 120 | dash = shutil.which("dash") | ||
| 121 | if dash is None: | ||
| 122 | self.skipTest("No \"dash\" found on test system.") | ||
| 123 | self.run_oegitproxy(custom_shell=dash) | ||
