Best Python code snippet using yandex-tank
wscript
Source:wscript
1#! /usr/bin/env python2import os, re3from waf_dynamo import is_platform_private, platform_supports_feature4from BuildUtility import create_build_utility5def create_test(bld, name, extra_libs = None, extra_features = None, embed_source = None,6 extra_includes = None, extra_defines = None, skip_run = False):7 # Sometimes, we need to disable certain tests until they're supported8 if not platform_supports_feature(bld.env.PLATFORM, name, {}):9 print "Skipping test '%s' due to platform missing feature" % name10 return11 build_util = create_build_utility(bld.env)12 req_libs = ['CARES']13 req_defines = []14 if 'DM_IPV6_UNSUPPORTED' in os.environ:15 req_defines += ['DM_IPV6_UNSUPPORTED']16 req_features = ['cxx', 'cprogram']17 req_includes = ['../../src']18 req_embed = None19 if is_platform_private(bld.env.PLATFORM):20 req_includes.insert(0, '../dlib/%s' % build_util.get_target_os())21 platform_source = ''22 platform_source_path = '%s/test_platform.cpp' % build_util.get_target_os()23 if os.path.exists('src/test/' + platform_source_path):24 platform_source = ' ' + platform_source_path25 if not skip_run:26 req_features.append('test')27 if extra_features != None:28 req_features.extend(extra_features)29 if extra_libs != None:30 req_libs.extend(extra_libs)31 if extra_defines != None:32 req_defines.extend(extra_defines)33 if embed_source != None:34 req_embed = embed_source35 if extra_includes != None:36 req_includes.extend(extra_includes)37 task_args = {38 'features': ' '.join(req_features),39 'source': name + '.cpp' + ' testutil.cpp' + platform_source,40 'uselib': ' '.join(req_libs),41 'uselib_local': 'dlib mbedtls zip',42 'web_libs': ['library_sys.js'], # part of dlib, which we're testing43 'includes': req_includes,44 'defines': req_defines,45 'target': name46 }47 if req_embed != None:48 task_args['embed_source'] = ' '.join(req_embed)49 test = bld.new_task_gen(**task_args)50 test.install_path = None51 js_lib_paths = {}52 js_lib_paths['library_sys.js'] = '../src/dlib/js'53 test.env['JS_LIB_PATHS'] = js_lib_paths54def build(bld):55 bld.new_task_gen(features='javac seq',56 classpath=os.pathsep.join(['../ext/jetty-all-7.0.2.v20100331.jar','../ext/servlet-api-2.5.jar']),57 source_root='http_server')58 bld.env["JAVACFLAGS"] = '-g -source 1.7 -target 1.7'.split()59 extra_defines = []60 if bld.env.PLATFORM in ('armv7-darwin', 'arm64-darwin', 'x86_64-ios'):61 extra_defines = ['DM_NO_SYSTEM_FUNCTION'] # Needed because we wish to build the tests for all platforms, but not all platforms have the system() function62 skip_run = False63 if 'web' in bld.env['PLATFORM']:64 skip_run = True # Emscripten/Nodejs doesn't support popen()65 skip_http_run = False66 if 'win32' in bld.env['PLATFORM']:67 skip_http_run = True68 create_test(bld, 'test_memory')69 create_test(bld, 'test_align', extra_libs = ['THREAD'])70 create_test(bld, 'test_buffer')71 create_test(bld, 'test_math', extra_libs = ['THREAD'])72 create_test(bld, 'test_transform', extra_libs = ['THREAD'])73 create_test(bld, 'test_hashtable')74 create_test(bld, 'test_array')75 create_test(bld, 'test_indexpool')76 create_test(bld, 'test_dlib', extra_libs = ['THREAD'])77 create_test(bld, 'test_socket', extra_libs = ['PLATFORM_SOCKET', 'THREAD'])78 create_test(bld, 'test_time')79 create_test(bld, 'test_thread', extra_libs = ['THREAD'])80 create_test(bld, 'test_mutex', extra_libs =['THREAD'])81 create_test(bld, 'test_profile', extra_libs = ['THREAD'])82 create_test(bld, 'test_poolallocator', extra_libs = ['THREAD'])83 create_test(bld, 'test_memprofile', extra_libs = ['DL', 'PLATFORM_SOCKET', 'THREAD'])84 create_test(bld, 'test_message', extra_libs = ['PLATFORM_SOCKET', 'THREAD'])85 create_test(bld, 'test_configfile', extra_libs = ['PLATFORM_SOCKET', 'THREAD'])86 create_test(bld, 'test_dstrings', extra_libs = ['THREAD'])87 create_test(bld, 'test_httpclient', extra_libs = ['PLATFORM_SOCKET', 'THREAD'], extra_defines = extra_defines, skip_run = skip_http_run)88 create_test(bld, 'test_httpcache', extra_libs = ['PLATFORM_SOCKET', 'THREAD'], extra_defines = extra_defines, skip_run = skip_http_run)89 create_test(bld, 'test_httpserver', extra_libs = ['PLATFORM_SOCKET', 'THREAD'], extra_defines = extra_defines, skip_run = skip_http_run)90 create_test(bld, 'test_webserver', extra_libs = ['PLATFORM_SOCKET', 'THREAD'], extra_defines = extra_defines, skip_run = skip_http_run)91 create_test(bld, 'test_uri', extra_libs = ['THREAD'])92 create_test(bld, 'test_stringpool', extra_libs = ['THREAD'])93 # c-ares not supported for web platform94 if not 'web' in bld.env['PLATFORM']:95 create_test(bld, 'test_dns')96 bld.new_task_gen(rule = 'echo generated data > ${TGT}',97 target = 'generated.embed')98 bld.add_group()99 create_test(bld, 'test_embed', extra_features = ['embed'], extra_libs = ['THREAD'],100 embed_source = ['data/test.embed', 'generated.embed'])101 create_test(bld, 'test_atomic', extra_libs = ['THREAD'])102 create_test(bld, 'test_spinlock', extra_libs = ['THREAD'])103 create_test(bld, 'test_sys', extra_libs = ['THREAD'], extra_defines = extra_defines)104 create_test(bld, 'test_template', extra_libs = ['THREAD'])105 create_test(bld, 'test_ssdp_internals', extra_libs = ['THREAD'])106 create_test(bld, 'test_ssdp', extra_libs = ['THREAD'], skip_run = skip_run)107 create_test(bld, 'test_log', extra_libs = ['THREAD'], skip_run = skip_http_run)108 create_test(bld, 'test_path', extra_libs = ['THREAD'])109 create_test(bld, 'test_trig_lookup', extra_libs = ['THREAD'])110 create_test(bld, 'test_vmath', extra_libs = ['THREAD'])111 create_test(bld, 'test_easing', extra_libs = ['THREAD'])112 create_test(bld, 'test_json', extra_features = ['embed'], extra_libs = ['THREAD'],113 embed_source = ['data/flickr.json'], extra_includes = ['.'])114 create_test(bld, 'test_utf8', extra_libs = ['THREAD'])115 create_test(bld, 'test_zip', extra_features = ['embed'], extra_libs = ['THREAD'], embed_source = ['data/foo.zip'])116 create_test(bld, 'test_zlib', extra_features = ['embed'], extra_libs = ['THREAD'],117 embed_source = ['data/foo.gz', 'data/foo.deflate'])118 create_test(bld, 'test_lz4', extra_features = ['embed'], extra_libs = ['THREAD'],119 embed_source = ['data/foo.lz4'])120 create_test(bld, 'test_image', extra_features = ['embed'], extra_libs = ['THREAD'],121 embed_source = ['data/color_check_2x2.png',122 'data/color_check_2x2_premult.png',123 'data/color_check_2x2_indexed.png',124 'data/case2319.jpg',125 'data/color16_check_2x2.png',126 'data/gray_check_2x2.png',127 'data/gray_alpha_check_2x2.png',128 'data/defold_64.jpg',129 'data/defold_64_progressive.jpg'],130 extra_includes = ['.']131 )132 create_test(bld, 'test_connection_pool', extra_features = ['embed'], extra_libs = ['THREAD'],133 extra_includes = ['.'], extra_defines = extra_defines)134 create_test(bld, 'test_pprint', extra_libs = ['THREAD'])135 create_test(bld, 'test_condition_variable', extra_libs = ['THREAD'])136 create_test(bld, 'test_objectpool')...
main.py
Source:main.py
...30 tester = Tester(fpga250, exec_sim_file, cmd_dir)31 # add tests32# for y in range(MY):33# for x in range(MX-1):34# tester.create_test("test1_y%d_x%d" % (y, x), test1, y, x)35#36# for y in range(MY):37# for x in range(MX-1):38# tester.create_test("test2_y%d_x%d" % (y, x), test2, y, x)39#40# for y in range(MY):41# for x in range(MX-1):42# tester.create_test("test3_y%d_x%d" % (y, x), test3, y, x)43#44# for y in range(MY):45# for x in range(MX-1):46# tester.create_test("test4_y%d_x%d" % (y, x), test4, y, x)47 tester.create_test("test1_y%d_x%d" % (0, 0), test1, 0, 0)48 tester.create_test("test2_y%d_x%d" % (0, 0), test1, 0, 0)49 tester.create_test("test3_y%d_x%d" % (0, 0), test1, 0, 0)50 tester.create_test("test4_y%d_x%d" % (0, 0), test1, 0, 0)51 tester.create_test("test5", test5)52 tester.create_test("test6", test6)53 tester.create_test("test7", test7)54 tester.create_test("test8", test8)55 tester.create_test("test9", test9)56 tester.create_test("test10", test10)57 tester.create_test("test12", test12)58 tester.create_test("test13", test13)59# tester.create_test("test11", test11)60# tester.create_test("test14", test14)61# tester.create_test("test15", test15)62# tester.create_test("test16", test16)63# tester.create_test("test17", test17)64# tester.create_test("test18", test18)65# tester.create_test("test19", test19)66# tester.create_test("test20", test20)67# tester.create_test("test21", test21)68# tester.create_test("test22", test22)69 # run all tests70 tester.run()71 # verify the results...
generate_test_graphs.py
Source:generate_test_graphs.py
1from random import random, shuffle2from math import ceil3MAX_WEIGHT = 54def create_test(num_vertices, branch_factor):5 E = []6 V = []7 # generate a list of verices in random order8 for i in range(num_vertices):9 V.append(i+1)10 shuffle(V)11 # create trivial Hamiltonian cycle (connect all vertices12 # with edges of weight 1)13 for i in range(num_vertices-1):14 E.append((V[i], V[i+1], 1))15 E.append((V[i+1], V[0], 1))16 for n in range(branch_factor-1):17 for i in range(num_vertices-1):18 E.append((V[i], V[i+1], ceil(MAX_WEIGHT*random())))19 E.append((V[i+1], V[0], ceil(MAX_WEIGHT*random())))20 print("TSPState(\"Start\", 0, None, [], " + str(V) + ", [], " + str(E) + ", " + str(num_vertices) + ")")21# we redirect output of this program to a txt file to get these tests22create_test(5, 1)23create_test(5, 2)24create_test(5, 3)25create_test(5, 5)26create_test(5, 10)27create_test(5, 1)28create_test(5, 2)29create_test(5, 3)30create_test(5, 5)31create_test(5, 10)32create_test(5, 1)33create_test(5, 2)34create_test(5, 3)35create_test(5, 5)36create_test(5, 10)37create_test(5, 1)38create_test(5, 2)39create_test(5, 3)40create_test(5, 5)41create_test(5, 10)42create_test(5, 1)43create_test(5, 2)44create_test(5, 3)45create_test(5, 5)46create_test(5, 10)47create_test(10, 1)48create_test(10, 2)49create_test(10, 3)50create_test(10, 4)51create_test(10, 1)52create_test(10, 2)53create_test(10, 3)54create_test(10, 4)55create_test(10, 1)56create_test(10, 2)57create_test(10, 3)58create_test(10, 4)59create_test(10, 1)60create_test(10, 2)61create_test(10, 3)62create_test(10, 4)63create_test(10, 1)64create_test(10, 2)65create_test(10, 3)66create_test(10, 4)67create_test(15, 1)68create_test(15, 2)69create_test(15, 1)70create_test(15, 2)71create_test(15, 1)72create_test(15, 2)73create_test(15, 1)74create_test(15, 2)75create_test(15, 1)76create_test(15, 2)77create_test(15, 1)78create_test(15, 2)79print("MST tests")80create_test(5, 10)81create_test(10, 10)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!