How to use check_output method in fMBT

Best Python code snippet using fMBT_python

test_xcrun.py

Source:test_xcrun.py Github

copy

Full Screen

1# This source file is part of the Swift.org open source project2#3# Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors4# Licensed under Apache License v2.0 with Runtime Library Exception5#6# See https://swift.org/LICENSE.txt for license information7# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors8from __future__ import absolute_import, unicode_literals9import os.path10import unittest11from build_swift import shell12from build_swift.versions import Version13from build_swift.wrappers import _xcrun14from ... import utils15try:16 # Python 317 from unittest import mock18except ImportError:19 pass20# -----------------------------------------------------------------------------21# Constants22_UNKNOWN_TOOL = 'gcc'23_KNOWN_TOOL = 'clang'24_KNOWN_TOOL_PATH = os.path.join(os.sep, 'usr', 'bin', _KNOWN_TOOL)25_UNKNOWN_SDK = 'phoneyos'26_KNOWN_SDK = 'macosx'27_KNOWN_SDK_PATH = os.path.join(os.sep, 'path', 'to', 'sdk')28_KNOWN_SDK_VERSION = '10.15'29_KNOWN_SDK_BUILD_VERSION = '10Z42b'30_KNOWN_SDK_PLATFORM_PATH = os.path.join(_KNOWN_SDK_PATH, 'platform')31_KNOWN_SDK_PLATFORM_VERSION = '10.15'32# -----------------------------------------------------------------------------33class TestXcrunHelpers(unittest.TestCase):34 """Unit tests for the helper functions and decorators defined in35 build_swift.wrappers.xcrun.36 """37 # -------------------------------------------------------------------------38 # _catch_return_none39 def test_catch_return_none_raises_returns_none(self):40 @_xcrun._catch_return_none(Exception)41 def raises():42 raise Exception43 self.assertIsNone(raises())44 def test_catch_return_none_success_return_value(self):45 @_xcrun._catch_return_none(Exception)46 def succeeds():47 return True48 self.assertTrue(succeeds())49 # -------------------------------------------------------------------------50 # _prepend_sdk_and_toolchain51 def test_prepend_sdk_and_toolchain(self):52 class Test(object):53 @_xcrun._prepend_sdk_and_toolchain54 def method(self, args, **kwargs):55 return args56 obj = Test()57 self.assertEqual(obj.method([]), [])58 self.assertEqual(59 obj.method([], sdk='some-sdk'),60 ['--sdk', 'some-sdk'])61 self.assertEqual(62 obj.method([], toolchain='some-toolchain'),63 ['--toolchain', 'some-toolchain'])64 self.assertEqual(65 obj.method([], sdk='some-sdk', toolchain='some-toolchain'),66 ['--sdk', 'some-sdk', '--toolchain', 'some-toolchain'])67class TestXcrunWrapper(unittest.TestCase):68 """Unit tests for the XcrunWrapper defined in build_swift.wrappers.xcrun.69 """70 def setUp(self):71 self.xcrun = _xcrun.XcrunWrapper()72 # -------------------------------------------------------------------------73 # version74 @utils.requires_module('unittest.mock')75 def test_version_error_returns_none(self):76 with mock.patch('build_swift.shell.check_output') as check_output:77 check_output.side_effect = shell.CalledProcessError(-1, None)78 result = self.xcrun.version79 check_output.assert_called_with([self.xcrun.EXECUTABLE, '--version'])80 self.assertIsNone(result)81 @utils.requires_module('unittest.mock')82 def test_version_invalid_version_string(self):83 with mock.patch('build_swift.shell.check_output') as check_output:84 check_output.side_effect = 'Invalid version output!\n'85 result = self.xcrun.version86 check_output.assert_called_with([self.xcrun.EXECUTABLE, '--version'])87 self.assertIsNone(result)88 @utils.requires_module('unittest.mock')89 def test_version(self):90 with mock.patch('build_swift.shell.check_output') as check_output:91 check_output.return_value = 'xcrun version 42.\n'92 result = self.xcrun.version93 check_output.assert_called_with([self.xcrun.EXECUTABLE, '--version'])94 self.assertEqual(result, Version('42'))95 # -------------------------------------------------------------------------96 # find97 @utils.requires_module('unittest.mock')98 def test_find_missing_tool(self):99 with mock.patch('build_swift.shell.check_output') as check_output:100 check_output.side_effect = shell.CalledProcessError(-1, None)101 result = self.xcrun.find(_UNKNOWN_TOOL, sdk=_KNOWN_SDK)102 command = [103 self.xcrun.EXECUTABLE,104 '--sdk', _KNOWN_SDK,105 '--find', _UNKNOWN_TOOL,106 ]107 check_output.assert_called_with(command, stderr=shell.DEVNULL)108 self.assertIsNone(result)109 @utils.requires_module('unittest.mock')110 def test_find_existing_tool(self):111 with mock.patch('build_swift.shell.check_output') as check_output:112 check_output.return_value = '{}\n'.format(_KNOWN_TOOL_PATH)113 result = self.xcrun.find(_KNOWN_TOOL, sdk=_KNOWN_SDK)114 command = [115 self.xcrun.EXECUTABLE,116 '--sdk', _KNOWN_SDK,117 '--find', _KNOWN_TOOL,118 ]119 check_output.assert_called_with(command, stderr=shell.DEVNULL)120 self.assertEqual(result, _KNOWN_TOOL_PATH)121 # -------------------------------------------------------------------------122 # kill_cache123 @utils.requires_module('unittest.mock')124 def test_kill_cache(self):125 with mock.patch.object(self.xcrun, 'call') as mock_call:126 self.xcrun.kill_cache()127 mock_call.assert_called_with('--kill-cache')128 # -------------------------------------------------------------------------129 # sdk_path130 @utils.requires_module('unittest.mock')131 def test_sdk_path_unknown_sdk(self):132 with mock.patch('build_swift.shell.check_output') as check_output:133 check_output.side_effect = shell.CalledProcessError(-1, None)134 result = self.xcrun.sdk_path(sdk=_UNKNOWN_SDK)135 command = [136 self.xcrun.EXECUTABLE,137 '--sdk', _UNKNOWN_SDK,138 '--show-sdk-path',139 ]140 check_output.assert_called_with(command, stderr=shell.DEVNULL)141 self.assertIsNone(result)142 @utils.requires_module('unittest.mock')143 def test_sdk_path_known_sdk(self):144 with mock.patch('build_swift.shell.check_output') as check_output:145 check_output.return_value = '{}\n'.format(_KNOWN_SDK_PATH)146 result = self.xcrun.sdk_path(sdk=_KNOWN_SDK)147 command = [148 self.xcrun.EXECUTABLE,149 '--sdk', _KNOWN_SDK,150 '--show-sdk-path',151 ]152 check_output.assert_called_with(command, stderr=shell.DEVNULL)153 self.assertEqual(result, _KNOWN_SDK_PATH)154 # -------------------------------------------------------------------------155 # sdk_version156 @utils.requires_module('unittest.mock')157 def test_sdk_version_unknown_sdk(self):158 with mock.patch('build_swift.shell.check_output') as check_output:159 check_output.side_effect = shell.CalledProcessError(-1, None)160 result = self.xcrun.sdk_version(sdk=_UNKNOWN_SDK)161 command = [162 self.xcrun.EXECUTABLE,163 '--sdk', _UNKNOWN_SDK,164 '--show-sdk-version',165 ]166 check_output.assert_called_with(command, stderr=shell.DEVNULL)167 self.assertIsNone(result)168 @utils.requires_module('unittest.mock')169 def test_sdk_version_known_sdk(self):170 with mock.patch('build_swift.shell.check_output') as check_output:171 check_output.return_value = '{}\n'.format(_KNOWN_SDK_VERSION)172 result = self.xcrun.sdk_version(sdk=_KNOWN_SDK)173 command = [174 self.xcrun.EXECUTABLE,175 '--sdk', _KNOWN_SDK,176 '--show-sdk-version',177 ]178 check_output.assert_called_with(command, stderr=shell.DEVNULL)179 self.assertEqual(result, Version(_KNOWN_SDK_VERSION))180 # -------------------------------------------------------------------------181 # sdk_build_version182 @utils.requires_module('unittest.mock')183 def test_sdk_build_version_unknown_sdk(self):184 with mock.patch('build_swift.shell.check_output') as check_output:185 check_output.side_effect = shell.CalledProcessError(-1, None)186 result = self.xcrun.sdk_build_version(sdk=_UNKNOWN_SDK)187 command = [188 self.xcrun.EXECUTABLE,189 '--sdk', _UNKNOWN_SDK,190 '--show-sdk-build-version',191 ]192 check_output.assert_called_with(command, stderr=shell.DEVNULL)193 self.assertIsNone(result)194 @utils.requires_module('unittest.mock')195 def test_sdk_build_version_known_sdk(self):196 with mock.patch('build_swift.shell.check_output') as check_output:197 check_output.return_value = '{}\n'.format(_KNOWN_SDK_BUILD_VERSION)198 result = self.xcrun.sdk_build_version(sdk=_KNOWN_SDK)199 command = [200 self.xcrun.EXECUTABLE,201 '--sdk', _KNOWN_SDK,202 '--show-sdk-build-version',203 ]204 check_output.assert_called_with(command, stderr=shell.DEVNULL)205 self.assertEqual(result, Version(_KNOWN_SDK_BUILD_VERSION))206 # -------------------------------------------------------------------------207 # sdk_platform_path208 @utils.requires_module('unittest.mock')209 def test_sdk_platform_path_unknown_sdk(self):210 with mock.patch('build_swift.shell.check_output') as check_output:211 check_output.side_effect = shell.CalledProcessError(-1, None)212 result = self.xcrun.sdk_platform_path(sdk=_UNKNOWN_SDK)213 command = [214 self.xcrun.EXECUTABLE,215 '--sdk', _UNKNOWN_SDK,216 '--show-sdk-platform-path',217 ]218 check_output.assert_called_with(command, stderr=shell.DEVNULL)219 self.assertIsNone(result)220 @utils.requires_module('unittest.mock')221 def test_sdk_platform_path_known_sdk(self):222 with mock.patch('build_swift.shell.check_output') as check_output:223 check_output.return_value = '{}\n'.format(_KNOWN_SDK_PLATFORM_PATH)224 result = self.xcrun.sdk_platform_path(sdk=_KNOWN_SDK)225 command = [226 self.xcrun.EXECUTABLE,227 '--sdk', _KNOWN_SDK,228 '--show-sdk-platform-path',229 ]230 check_output.assert_called_with(command, stderr=shell.DEVNULL)231 self.assertEqual(result, _KNOWN_SDK_PLATFORM_PATH)232 # -------------------------------------------------------------------------233 # sdk_platform_version234 @utils.requires_module('unittest.mock')235 def test_sdk_platform_version_unknown_sdk(self):236 with mock.patch('build_swift.shell.check_output') as check_output:237 check_output.side_effect = shell.CalledProcessError(-1, None)238 result = self.xcrun.sdk_platform_version(sdk=_UNKNOWN_SDK)239 command = [240 self.xcrun.EXECUTABLE,241 '--sdk', _UNKNOWN_SDK,242 '--show-sdk-platform-version',243 ]244 check_output.assert_called_with(command, stderr=shell.DEVNULL)245 self.assertIsNone(result)246 @utils.requires_module('unittest.mock')247 def test_sdk_platform_version_known_sdk(self):248 with mock.patch('build_swift.shell.check_output') as check_output:249 check_output.return_value = '{}\n'.format(250 _KNOWN_SDK_PLATFORM_VERSION)251 result = self.xcrun.sdk_platform_version(sdk=_KNOWN_SDK)252 command = [253 self.xcrun.EXECUTABLE,254 '--sdk', _KNOWN_SDK,255 '--show-sdk-platform-version',256 ]257 check_output.assert_called_with(command, stderr=shell.DEVNULL)...

Full Screen

Full Screen

test_ls.py

Source:test_ls.py Github

copy

Full Screen

...7from datetime import datetime8from pymake.pymake import PyMake9class TestLS(unittest.TestCase):10 debug_mod = False11 kernel = subp.check_output(["uname", "-s"]).replace("\n", "")12 context_path = os.path.split(os.path.dirname(__file__))[0] + "/ls_%s/" % kernel.lower()13 makefile = PyMake(context_path + "Makefile")14 options = [opt for opt in "1lQRartUfgdG"]15 real_f, fake_f, null_f = glob.glob(context_path + "*"), [str(k) for k in xrange(50)], open(os.devnull, 'w')16 @classmethod17 def setUpClass(cls):18 [os.remove(binary) for binary in glob.glob(cls.context_path + "*.bft")]19 cls.makefile.make_fclean(), cls.makefile.make()20 cls.set_config = utils_config.SetLSConfig(cls.debug_mod)21 cls.test_methods = iter(utils_config.IterMethods(cls))22 @classmethod23 def tearDownClass(cls):24 cls.makefile.make_fclean(), cls.null_f.close()25 if cls.debug_mod is False:26 [os.remove(binary) for binary in glob.glob(cls.context_path + "*.bft")]27 def setUp(self):28 """29 iter to dry tests30 """31 self.run = self.set_config.next_conf(self.test_methods.next())32 def test_build_child_name(self):33 printed = subp.check_output([self.run, "-1a", "ls_mains/resources"]).split("\n")34 printed.sort()35 self.assertEqual(['', '.', '..', 'file_one'], printed)36 def test_build_child_path(self):37 printed = subp.check_output([self.run, "-1a", "ls_mains/resources"]).split("\n")38 printed.sort()39 self.assertEqual(['', 'ls_mains/resources/.', 'ls_mains/resources/..', 'ls_mains/resources/file_one'], printed)40 def test_build_path(self):41 self.assertEqual("parent/child", subp.check_output([self.run, "parent", "child"]))42 def test_display_date(self):43 self.assertEqual("Jan 1 1970 ", subp.check_output([self.run, "0"]))44 self.assertEqual("Sep 1 2014 ", subp.check_output([self.run, "1409529600"]))45 self.assertEqual("Dec 31 2014 ", subp.check_output([self.run, "1420066740"]))46 self.assertEqual("Dec 31 2014 ", subp.check_output([self.run, "1420066799"]))47 ts = time.time()48 today = datetime.fromtimestamp(ts).strftime('%b %d %H:%M ')49 if datetime.fromtimestamp(ts).strftime('%d')[0] == '0':50 today = datetime.fromtimestamp(ts).strftime('%b %-d %H:%M ')51 self.assertEqual(today, subp.check_output([self.run, str(ts)]))52 def test_long_display_00(self):53 real = subp.check_output(["ls", "-la", self.context_path + "/includes"])54 mine = subp.check_output([self.run, "-la", self.context_path + "/includes"])55 self.assertEqual(real, mine)56 def test_long_display_01(self):57 real = subp.check_output(["ls", "-la", self.context_path + "/srcs"])58 mine = subp.check_output([self.run, "-la", self.context_path + "/srcs"])59 self.assertEqual(real, mine)60 def test_long_display_02(self):61 real = subp.check_output(["ls", "-la", self.context_path])62 mine = subp.check_output([self.run, "-la", self.context_path])63 self.assertEqual(real, mine)64 def test_long_display_03(self):65 real = subp.check_output(["ls", "-la", "/usr/"])66 mine = subp.check_output([self.run, "-la", "/usr/"])67 self.assertEqual(real, mine)68 def test_long_display_04(self):69 usr_wild_card = glob.glob("/usr/*")70 real = subp.check_output(["ls", "-la"] + usr_wild_card)71 mine = subp.check_output([self.run, "-la"] + usr_wild_card)72 self.assertEqual(real, mine)73 def test_long_display_05(self):74 real = subp.check_output(["ls", "-la"] + self.real_f)75 mine = subp.check_output([self.run, "-la"] + self.real_f)76 self.assertEqual(real, mine)77 def test_long_display_06(self):78 real = subp.check_output(["ls", "-la", "/dev/"])79 mine = subp.check_output([self.run, "-la", "/dev/"])80 if self.kernel == "Linux":81 # TODO -> finish Linux xattr82 return83 self.assertEqual(real, mine)84 def test_long_display_07(self):85 dev_wild_card = glob.glob("/dev/")86 real = subp.check_output(["ls", "-la"] + dev_wild_card)87 mine = subp.check_output([self.run, "-la"] + dev_wild_card)88 if self.kernel == "Linux":89 # TODO -> finish Linux xattr90 return91 self.assertEqual(real, mine)92 def test_get_args(self):93 for real in self.real_f:94 self.assertEqual(real + "0", subp.check_output([self.run, real]))95 self.assertEqual(str(len(self.options)),96 subp.check_output([self.run, "-" + "".join(self.options), real]).split("\n")[-1])97 for opt in self.options:98 if opt == 'f':99 self.assertEqual(real + "3", subp.check_output([self.run, "-" + opt, real]).split("\n")[-1])100 else:101 try:102 self.assertEqual(real + "1", subp.check_output([self.run, "-" + opt, real]).split("\n")[-1])103 except AssertionError:104 self.assertEqual("1", subp.check_output([self.run, "-" + opt, real]).split("\n")[-1])105 for arg in self.options:106 if arg == 'f':107 self.assertEqual("3", subp.check_output([self.run, '-' + arg] + self.fake_f, stderr=self.null_f), )108 else:109 self.assertEqual("1", subp.check_output([self.run, '-' + arg] + self.fake_f, stderr=self.null_f), )110 self.assertEqual(str(len(self.options)),111 subp.check_output([self.run, "-" + "".join(self.options)] + self.fake_f,112 stderr=self.null_f))113 self.assertEqual("." + str(len(self.options)),114 subp.check_output([self.run, "--"] + ["-" + k for k in self.options]).split("\n")[-1])115 self.assertEqual(".0", subp.check_output([self.run, "--"]))116 for arg in self.options:117 if arg == 'f':118 self.assertEqual(".3", subp.check_output([self.run, "--", "-" + arg]).split("\n")[-1])119 else:120 self.assertEqual(".1", subp.check_output([self.run, "--", "-" + arg]).split("\n")[-1])121 def test_get_items(self):122 for real in self.real_f:123 self.assertEqual(real, subp.check_output([self.run, real]))124 for fake in self.fake_f:125 self.assertEqual(self.run + ": cannot access %s: No such file or directory\n" % fake,126 subp.check_output([self.run, fake], stderr=subp.STDOUT))127 self.assertEqual(self.run + ": cannot access -: No such file or directory\n",128 subp.check_output([self.run, "-"], stderr=subp.STDOUT))129 self.assertEqual(".", subp.check_output([self.run, "--"], stderr=self.null_f))130 def test_get_options(self):131 for opt in self.options:132 if opt == 'f':133 self.assertEqual("3", subp.check_output([self.run, '-' + opt]).split("\n")[-1])134 else:135 self.assertEqual("1", subp.check_output([self.run, '-' + opt]).split("\n")[-1])136 self.assertEqual(str(len(self.options)),137 subp.check_output([self.run, "-" + "".join(self.options)]).split("\n")[-1])138 self.assertEqual("2", subp.check_output([self.run, "-l", "-a"]).split("\n")[-1])139 self.assertEqual(str(len(self.options)),140 subp.check_output([self.run] + ["-" + k for k in self.options]).split("\n")[-1])141 def test_matrix_00(self):142 real = subp.check_output(["ls", self.context_path + "srcs/"])143 mine = subp.check_output([self.run, self.context_path + "srcs/"]).split(" ")144 mine = "\n".join([k for k in mine if k != "\n"])145 self.assertEqual(real, mine)146 def test_no_options(self):147 self.assertEqual(1, subp.call([self.run, "-l"])) # just to be sure148 # Test errors : ret code == 0149 error_msg = self.run + ': cannot access -%s: No such file or directory\n' # blank before -150 for arg in self.options:151 self.assertEqual(error_msg % arg, subp.check_output([self.run, ' -' + arg], stderr=subp.STDOUT))152 self.assertEqual(2, subp.call([self.run, "-l-"], stderr=self.null_f))153 self.assertEqual(2, subp.call([self.run, "-lza"], stderr=self.null_f))154 self.assertEqual(2, subp.call([self.run, "-".join(["-" + k for k in self.options])],155 stderr=self.null_f)) # e.g. -l-a-R ...156 def test_one_a(self):157 real, mine = subp.check_output(["ls", "-1a"]), subp.check_output([self.run, "-1a"])158 self.assertEqual(real, mine)159 real = subp.check_output(["ls", "-1a", ".", ".."])160 mine = subp.check_output([self.run, "-1a", ".", ".."])161 self.assertEqual(real, mine)162 real = subp.check_output(["ls", "-1a"] + self.real_f)163 mine = subp.check_output([self.run, "-1a"] + self.real_f)164 self.assertEqual(real, mine)165 def test_recursive_00(self):166 real = subp.check_output(["ls", "-1R", self.context_path])167 mine = subp.check_output([self.run, "-1R", self.context_path])168 self.assertEqual(real, mine)169 def test_recursive_01(self):170 real = subp.check_output(["ls", "-1aR", self.context_path])171 mine = subp.check_output([self.run, "-1aR", self.context_path])172 self.assertEqual(real, mine)173 def test_recursive_02(self):174 real = subp.check_output(["ls", "-1aR"])175 mine = subp.check_output([self.run, "-1aR"])176 self.assertEqual(real, mine)177 def test_recursive_03(self):178 real = subp.check_output(["ls", "-laR"])179 mine = subp.check_output([self.run, "-laR"])180 self.assertEqual(real, mine)181 def test_recursive_04(self):182 real = subp.check_output(["ls", "-lR", self.context_path])183 mine = subp.check_output([self.run, "-lR", self.context_path])184 # self.assertEqual(real, mine) TODO185 def test_short_display(self):186 m_one_a = subp.check_output([self.run, "-1a", "."]).split("\n")187 r_one_a = subp.check_output(["ls", "-a1"]).split("\n")188 self.assertEqual(len(r_one_a), len(m_one_a)), self.assertEqual(set(r_one_a), set(m_one_a)) # unsorted189 def test_reverse_00(self):190 real = subp.check_output(["ls", "-1ar"])191 mine = subp.check_output([self.run, "-1ar"])192 self.assertEqual(real, mine)193 def test_reverse_01(self):194 real = subp.check_output(["ls", "-lar"])195 mine = subp.check_output([self.run, "-lar"])196 self.assertEqual(real, mine)197 def test_reverse_02(self):198 real = subp.check_output(["ls", "-ltr", "/"])199 mine = subp.check_output([self.run, "-ltr", "/"])200 if self.kernel == "Linux":201 # TODO202 return203 self.assertEqual(real, mine)204 def test_reverse_03(self):205 real = subp.check_output(["ls", "-1tr", "/"])206 mine = subp.check_output([self.run, "-1tr", "/"])207 if self.kernel == "Linux":208 # TODO209 return210 self.assertEqual(real, mine)211 def test_time_00(self):212 real = subp.check_output(["ls", "-1t", "/"])213 mine = subp.check_output([self.run, "-1t", "/"])214 if self.kernel == "Linux":215 # TODO 216 return217 self.assertEqual(real, mine)218 def test_time_01(self):219 real = subp.check_output(["ls", "-lt", "/"])220 mine = subp.check_output([self.run, "-lt", "/"])221 if self.kernel == "Linux":222 # TODO223 return224 self.assertEqual(real, mine)225 def test_valgrind_errors(self):226 slow = True # Very Slow at True because of Valgrind227 if slow is False:228 return229 self.assertFalse(utils_config.valgrind_wrapper(self.run, errors=True, args=["-1"])) # Will get file "."230 self.assertFalse(utils_config.valgrind_wrapper(self.run, errors=True, args=[".", "..", "-1"]))231 self.assertFalse(utils_config.valgrind_wrapper(self.run, errors=True, args=["-l"]))232 self.assertFalse(utils_config.valgrind_wrapper(self.run, errors=True, args=["-1R"]))233 self.assertFalse(utils_config.valgrind_wrapper(self.run, errors=True, args=["-lR"]))234 def test_valgrind_leaks(self):...

Full Screen

Full Screen

get_pretrained_checkpoints.py

Source:get_pretrained_checkpoints.py Github

copy

Full Screen

1import subprocess2###############################3# VGG Net4###############################5subprocess.check_output(['wget','http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz'])6subprocess.check_output(['tar', '-xvf', 'vgg_16_2016_08_28.tar.gz'])7subprocess.check_output(['mv', 'vgg_16.ckpt', 'weights'])8subprocess.check_output(['rm', 'vgg_16_2016_08_28.tar.gz'])9subprocess.check_output(['wget','http://download.tensorflow.org/models/vgg_19_2016_08_28.tar.gz'])10subprocess.check_output(['tar', '-xvf', 'vgg_19_2016_08_28.tar.gz'])11subprocess.check_output(['mv', 'vgg_19.ckpt', 'weights'])12subprocess.check_output(['rm', 'vgg_19_2016_08_28.tar.gz'])13###############################14# Inception Net15###############################16subprocess.check_output(['wget','http://download.tensorflow.org/models/inception_v1_2016_08_28.tar.gz'])17subprocess.check_output(['tar', '-xvf', 'inception_v1_2016_08_28.tar.gz'])18subprocess.check_output(['mv', 'inception_v1.ckpt', 'weights'])19subprocess.check_output(['rm', 'inception_v1_2016_08_28.tar.gz'])20subprocess.check_output(['wget','http://download.tensorflow.org/models/inception_v2_2016_08_28.tar.gz'])21subprocess.check_output(['tar', '-xvf', 'inception_v2_2016_08_28.tar.gz'])22subprocess.check_output(['mv', 'inception_v2.ckpt', 'weights'])23subprocess.check_output(['rm', 'inception_v2_2016_08_28.tar.gz'])24subprocess.check_output(['wget','http://download.tensorflow.org/models/inception_v3_2016_08_28.tar.gz'])25subprocess.check_output(['tar', '-xvf', 'inception_v3_2016_08_28.tar.gz'])26subprocess.check_output(['mv', 'inception_v3.ckpt', 'weights'])27subprocess.check_output(['rm', 'inception_v3_2016_08_28.tar.gz'])28subprocess.check_output(['wget','http://download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz'])29subprocess.check_output(['tar', '-xvf', 'inception_v4_2016_09_09.tar.gz'])30subprocess.check_output(['mv', 'inception_v4.ckpt', 'weights'])31subprocess.check_output(['rm', 'inception_v4_2016_09_09.tar.gz'])32subprocess.check_output(['wget','http://download.tensorflow.org/models/inception_resnet_v2_2016_08_30.tar.gz'])33subprocess.check_output(['tar', '-xvf', 'inception_resnet_v2_2016_08_30.tar.gz'])34subprocess.check_output(['mv', 'inception_resnet_v2.ckpt', 'weights'])35subprocess.check_output(['rm', 'inception_resnet_v2_2016_08_30.tar.gz'])36###############################37# ResNet V138###############################39subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz'])40subprocess.check_output(['tar', '-xvf', 'resnet_v1_50_2016_08_28.tar.gz'])41subprocess.check_output(['mv', 'resnet_v1_50.ckpt', 'weights'])42subprocess.check_output(['rm', 'resnet_v1_50_2016_08_28.tar.gz'])43subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v1_101_2016_08_28.tar.gz'])44subprocess.check_output(['tar', '-xvf', 'resnet_v1_101_2016_08_28.tar.gz'])45subprocess.check_output(['mv', 'resnet_v1_101.ckpt', 'weights'])46subprocess.check_output(['rm', 'resnet_v1_101_2016_08_28.tar.gz'])47subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v1_152_2016_08_28.tar.gz'])48subprocess.check_output(['tar', '-xvf', 'resnet_v1_152_2016_08_28.tar.gz'])49subprocess.check_output(['mv', 'resnet_v1_152.ckpt', 'weights'])50subprocess.check_output(['rm', 'resnet_v1_152_2016_08_28.tar.gz'])51###############################52# ResNet V253###############################54subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v2_50_2017_04_14.tar.gz'])55subprocess.check_output(['tar', '-xvf', 'resnet_v2_50_2017_04_14.tar.gz'])56subprocess.check_output(['mv', 'resnet_v2_50.ckpt', 'weights'])57subprocess.check_output(['rm', 'resnet_v2_50_2017_04_14.tar.gz'])58subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v2_101_2017_04_14.tar.gz'])59subprocess.check_output(['tar', '-xvf', 'resnet_v2_101_2017_04_14.tar.gz'])60subprocess.check_output(['mv', 'resnet_v2_101.ckpt', 'weights'])61subprocess.check_output(['rm', 'resnet_v2_101_2017_04_14.tar.gz'])62subprocess.check_output(['wget','http://download.tensorflow.org/models/resnet_v2_152_2017_04_14.tar.gz'])63subprocess.check_output(['tar', '-xvf', 'resnet_v2_152_2017_04_14.tar.gz'])64subprocess.check_output(['mv', 'resnet_v2_152.ckpt', 'weights'])...

Full Screen

Full Screen

test_simple_progs.py

Source:test_simple_progs.py Github

copy

Full Screen

...20 compile_b('f1(){ extrn putchar; putchar(65); }')21def test_names_with_backspace(compile_b):22 compile_b('m\byfunc(){ }')23def test_simple_expression(check_output):24 check_output('main() { extrn putnumb; putnumb(2-3-4); }', '-5')25 check_output('main() { extrn putnumb; putnumb(4+10*2); }', '24')26 check_output('main() { extrn putnumb; putnumb(5 & 2); }', '0')27 check_output('main() { extrn putnumb; putnumb(7 & 2); }', '2')28def test_func_call(check_output):29 check_output('''30 main() { extrn putnumb; putnumb(sub(3,4)); }31 sub(a, b) { return (a-b); }32 ''', '-1')33def test_simple_auto(check_output):34 check_output('''35 main() {36 extrn putnumb;37 auto a, b;38 a = 4; b = 10;39 putnumb(b-a);40 }41 ''', '6')42def test_hello_world(check_output):43 check_output('''44 main() {45 extrn putchar;46 putchar('hell');47 putchar('o, w');48 putchar('orld');49 }50 ''', 'hello, world')51def test_recursion(check_output):52 check_output('''53 fact(n) if(n == 0) return(1); else return (n*fact(n-1));54 check(a, b) {55 extrn putchar;56 if(a != b)57 putchar('x');58 else59 putchar('.');60 }61 main() {62 check(fact(0), 1);63 check(fact(1), 1);64 check(fact(2), 2);65 check(fact(3), 6);66 check(fact(4), 24);67 }68 ''', '.....')69def test_zero_extrn(check_output):70 check_output('''71 main() {72 extrn a, putnumb;73 putnumb(a + 5);74 }75 a;76 ''', '5')77def test_extrn_hello_world(check_output):78 check_output('''79 main() {80 extrn a, b, c, putchar;81 putchar(a); putchar(b); putchar(c); putchar('!*n');82 }83 a 'hell';84 b 'o, w';85 c 'orld';86 ''', 'hello, world!\n')87def test_extrn_hello_world_2(check_output):88 check_output('''89 main( ) {90 extrn a,b,c,d;91 put2char(a,b) ;92 put2char(c,d) ;93 }94 put2char(x,y) {95 extrn putchar;96 putchar(x);97 putchar(y);98 }99 a 'hell'; b 'o, w'; c 'orld'; d '!*n';100 ''', 'hello, world!\n')101def test_setting_extrn(check_output):102 check_output('''103 main() {104 extrn putnumb, val;105 addval(5);106 addval(3);107 putnumb(val);108 }109 addval(x) {110 extrn val;111 val =+ x;112 }113 val;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful