Best Python code snippet using locust
bit_test.py
Source:bit_test.py
1# Copyright (c) 2007-2008 The Hewlett-Packard Development Company2# All rights reserved.3#4# The license below extends only to copyright in the software and shall5# not be construed as granting a license to any other intellectual6# property including but not limited to intellectual property relating7# to a hardware implementation of the functionality of the software8# licensed hereunder. You may use the software subject to the license9# terms below provided that you ensure that this notice is replicated10# unmodified and in its entirety in all distributions of the software,11# modified or unmodified, in source code or in binary form.12#13# Copyright (c) 2008 The Regents of The University of Michigan14# All rights reserved.15#16# Redistribution and use in source and binary forms, with or without17# modification, are permitted provided that the following conditions are18# met: redistributions of source code must retain the above copyright19# notice, this list of conditions and the following disclaimer;20# redistributions in binary form must reproduce the above copyright21# notice, this list of conditions and the following disclaimer in the22# documentation and/or other materials provided with the distribution;23# neither the name of the copyright holders nor the names of its24# contributors may be used to endorse or promote products derived from25# this software without specific prior written permission.26#27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.38#39# Authors: Gabe Black40microcode = '''41def macroop BT_R_I {42 sexti t0, reg, imm, flags=(CF,)43};44def macroop BT_M_I {45 limm t1, imm, dataSize=asz46 # This fudges just a tiny bit, but it's reasonable to expect the47 # microcode generation logic to have the log of the various sizes48 # floating around as well.49 ld t1, seg, sib, disp50 sexti t0, t1, imm, flags=(CF,)51};52def macroop BT_P_I {53 rdip t754 limm t1, imm, dataSize=asz55 ld t1, seg, riprel, disp, dataSize=asz56 sexti t0, t1, imm, flags=(CF,)57};58def macroop BT_R_R {59 sext t0, reg, regm, flags=(CF,)60};61def macroop BT_M_R {62 srai t2, reg, 3, dataSize=asz63 srai t3, t2, ldsz, dataSize=asz64 lea t3, flatseg, [dsz, t3, base], dataSize=asz65 ld t1, seg, [scale, index, t3], disp66 sext t0, t1, reg, flags=(CF,)67};68def macroop BT_P_R {69 rdip t770 srai t2, reg, 3, dataSize=asz71 srai t3, t2, ldsz, dataSize=asz72 ld t1, seg, [dsz, t3, t7], disp73 sext t0, t1, reg, flags=(CF,)74};75def macroop BTC_R_I {76 sexti t0, reg, imm, flags=(CF,)77 limm t1, 178 roli t1, t1, imm79 xor reg, reg, t180};81def macroop BTC_M_I {82 limm t1, imm, dataSize=asz83 # This fudges just a tiny bit, but it's reasonable to expect the84 # microcode generation logic to have the log of the various sizes85 # floating around as well.86 limm t4, 187 roli t4, t4, imm88 ldst t1, seg, sib, disp89 sexti t0, t1, imm, flags=(CF,)90 xor t1, t1, t491 st t1, seg, sib, disp92};93def macroop BTC_P_I {94 rdip t7, dataSize=asz95 limm t1, imm, dataSize=asz96 limm t4, 197 roli t4, t4, imm98 ldst t1, seg, riprel, disp99 sexti t0, t1, imm, flags=(CF,)100 xor t1, t1, t4101 st t1, seg, riprel, disp102};103def macroop BTC_LOCKED_M_I {104 limm t1, imm, dataSize=asz105 limm t4, 1106 roli t4, t4, imm107 mfence108 ldstl t1, seg, sib, disp109 sexti t0, t1, imm, flags=(CF,)110 xor t1, t1, t4111 stul t1, seg, sib, disp112 mfence113};114def macroop BTC_LOCKED_P_I {115 rdip t7, dataSize=asz116 limm t1, imm, dataSize=asz117 limm t4, 1118 roli t4, t4, imm119 mfence120 ldstl t1, seg, riprel, disp121 sexti t0, t1, imm, flags=(CF,)122 xor t1, t1, t4123 stul t1, seg, riprel, disp124 mfence125};126def macroop BTC_R_R {127 sext t0, reg, regm, flags=(CF,)128 limm t1, 1129 rol t1, t1, regm130 xor reg, reg, t1131};132def macroop BTC_M_R {133 srai t2, reg, 3, dataSize=asz134 srai t3, t2, ldsz, dataSize=asz135 lea t3, flatseg, [dsz, t3, base], dataSize=asz136 limm t4, 1137 rol t4, t4, reg138 ldst t1, seg, [scale, index, t3], disp139 sext t0, t1, reg, flags=(CF,)140 xor t1, t1, t4141 st t1, seg, [scale, index, t3], disp142};143def macroop BTC_P_R {144 rdip t7, dataSize=asz145 srai t2, reg, 3, dataSize=asz146 srai t3, t2, ldsz, dataSize=asz147 limm t4, 1148 rol t4, t4, reg149 ldst t1, seg, [dsz, t3, t7], disp150 sext t0, t1, reg, flags=(CF,)151 xor t1, t1, t4152 st t1, seg, [dsz, t3, t7], disp153};154def macroop BTC_LOCKED_M_R {155 srai t2, reg, 3, dataSize=asz156 srai t3, t2, ldsz, dataSize=asz157 lea t3, flatseg, [dsz, t3, base], dataSize=asz158 limm t4, 1159 rol t4, t4, reg160 mfence161 ldstl t1, seg, [scale, index, t3], disp162 sext t0, t1, reg, flags=(CF,)163 xor t1, t1, t4164 stul t1, seg, [scale, index, t3], disp165 mfence166};167def macroop BTC_LOCKED_P_R {168 rdip t7, dataSize=asz169 srai t2, reg, 3, dataSize=asz170 srai t3, t2, ldsz, dataSize=asz171 limm t4, 1172 rol t4, t4, reg173 mfence174 ldstl t1, seg, [dsz, t3, t7], disp175 sext t0, t1, reg, flags=(CF,)176 xor t1, t1, t4177 stul t1, seg, [dsz, t3, t7], disp178 mfence179};180def macroop BTR_R_I {181 sexti t0, reg, imm, flags=(CF,)182 limm t1, "(uint64_t(-(2ULL)))"183 roli t1, t1, imm184 and reg, reg, t1185};186def macroop BTR_M_I {187 limm t1, imm, dataSize=asz188 limm t4, "(uint64_t(-(2ULL)))"189 roli t4, t4, imm190 ldst t1, seg, sib, disp191 sexti t0, t1, imm, flags=(CF,)192 and t1, t1, t4193 st t1, seg, sib, disp194};195def macroop BTR_P_I {196 rdip t7, dataSize=asz197 limm t1, imm, dataSize=asz198 limm t4, "(uint64_t(-(2ULL)))"199 roli t4, t4, imm200 ldst t1, seg, riprel, disp201 sexti t0, t1, imm, flags=(CF,)202 and t1, t1, t4203 st t1, seg, riprel, disp204};205def macroop BTR_LOCKED_M_I {206 limm t1, imm, dataSize=asz207 limm t4, "(uint64_t(-(2ULL)))"208 roli t4, t4, imm209 mfence210 ldstl t1, seg, sib, disp211 sexti t0, t1, imm, flags=(CF,)212 and t1, t1, t4213 stul t1, seg, sib, disp214 mfence215};216def macroop BTR_LOCKED_P_I {217 rdip t7, dataSize=asz218 limm t1, imm, dataSize=asz219 limm t4, "(uint64_t(-(2ULL)))"220 roli t4, t4, imm221 mfence222 ldstl t1, seg, riprel, disp223 sexti t0, t1, imm, flags=(CF,)224 and t1, t1, t4225 stul t1, seg, riprel, disp226 mfence227};228def macroop BTR_R_R {229 sext t0, reg, regm, flags=(CF,)230 limm t1, "(uint64_t(-(2ULL)))"231 rol t1, t1, regm232 and reg, reg, t1233};234def macroop BTR_M_R {235 srai t2, reg, 3, dataSize=asz236 srai t3, t2, ldsz, dataSize=asz237 lea t3, flatseg, [dsz, t3, base], dataSize=asz238 limm t4, "(uint64_t(-(2ULL)))"239 rol t4, t4, reg240 ldst t1, seg, [scale, index, t3], disp241 sext t0, t1, reg, flags=(CF,)242 and t1, t1, t4243 st t1, seg, [scale, index, t3], disp244};245def macroop BTR_P_R {246 rdip t7, dataSize=asz247 srai t2, reg, 3, dataSize=asz248 srai t3, t2, ldsz, dataSize=asz249 limm t4, "(uint64_t(-(2ULL)))"250 rol t4, t4, reg251 ldst t1, seg, [dsz, t3, t7], disp252 sext t0, t1, reg, flags=(CF,)253 and t1, t1, t4254 st t1, seg, [dsz, t3, t7], disp255};256def macroop BTR_LOCKED_M_R {257 srai t2, reg, 3, dataSize=asz258 srai t3, t2, ldsz, dataSize=asz259 lea t3, flatseg, [dsz, t3, base], dataSize=asz260 limm t4, "(uint64_t(-(2ULL)))"261 rol t4, t4, reg262 mfence263 ldstl t1, seg, [scale, index, t3], disp264 sext t0, t1, reg, flags=(CF,)265 and t1, t1, t4266 stul t1, seg, [scale, index, t3], disp267 mfence268};269def macroop BTR_LOCKED_P_R {270 rdip t7, dataSize=asz271 srai t2, reg, 3, dataSize=asz272 srai t3, t2, ldsz, dataSize=asz273 limm t4, "(uint64_t(-(2ULL)))"274 rol t4, t4, reg275 mfence276 ldstl t1, seg, [dsz, t3, t7], disp277 sext t0, t1, reg, flags=(CF,)278 and t1, t1, t4279 stul t1, seg, [dsz, t3, t7], disp280 mfence281};282def macroop BTS_R_I {283 sexti t0, reg, imm, flags=(CF,)284 limm t1, 1285 roli t1, t1, imm286 or reg, reg, t1287};288def macroop BTS_M_I {289 limm t1, imm, dataSize=asz290 limm t4, 1291 roli t4, t4, imm292 ldst t1, seg, sib, disp293 sexti t0, t1, imm, flags=(CF,)294 or t1, t1, t4295 st t1, seg, sib, disp296};297def macroop BTS_P_I {298 rdip t7, dataSize=asz299 limm t1, imm, dataSize=asz300 limm t4, 1301 roli t4, t4, imm302 ldst t1, seg, riprel, disp303 sexti t0, t1, imm, flags=(CF,)304 or t1, t1, t4305 st t1, seg, riprel, disp306};307def macroop BTS_LOCKED_M_I {308 limm t1, imm, dataSize=asz309 limm t4, 1310 roli t4, t4, imm311 mfence312 ldstl t1, seg, sib, disp313 sexti t0, t1, imm, flags=(CF,)314 or t1, t1, t4315 stul t1, seg, sib, disp316 mfence317};318def macroop BTS_LOCKED_P_I {319 rdip t7, dataSize=asz320 limm t1, imm, dataSize=asz321 limm t4, 1322 roli t4, t4, imm323 mfence324 ldstl t1, seg, riprel, disp325 sexti t0, t1, imm, flags=(CF,)326 or t1, t1, t4327 stul t1, seg, riprel, disp328 mfence329};330def macroop BTS_R_R {331 sext t0, reg, regm, flags=(CF,)332 limm t1, 1333 rol t1, t1, regm334 or reg, reg, t1335};336def macroop BTS_M_R {337 srai t2, reg, 3, dataSize=asz338 srai t3, t2, ldsz, dataSize=asz339 lea t3, flatseg, [dsz, t3, base], dataSize=asz340 limm t4, 1341 rol t4, t4, reg342 ldst t1, seg, [scale, index, t3], disp343 sext t0, t1, reg, flags=(CF,)344 or t1, t1, t4345 st t1, seg, [scale, index, t3], disp346};347def macroop BTS_P_R {348 rdip t7, dataSize=asz349 srai t2, reg, 3, dataSize=asz350 srai t3, t2, ldsz, dataSize=asz351 lea t3, flatseg, [dsz, t3, base], dataSize=asz352 limm t4, 1353 rol t4, t4, reg354 ldst t1, seg, [1, t3, t7], disp355 sext t0, t1, reg, flags=(CF,)356 or t1, t1, t4357 st t1, seg, [1, t3, t7], disp358};359def macroop BTS_LOCKED_M_R {360 srai t2, reg, 3, dataSize=asz361 srai t3, t2, ldsz, dataSize=asz362 lea t3, flatseg, [dsz, t3, base], dataSize=asz363 limm t4, 1364 rol t4, t4, reg365 mfence366 ldstl t1, seg, [scale, index, t3], disp367 sext t0, t1, reg, flags=(CF,)368 or t1, t1, t4369 stul t1, seg, [scale, index, t3], disp370 mfence371};372def macroop BTS_LOCKED_P_R {373 rdip t7, dataSize=asz374 srai t2, reg, 3, dataSize=asz375 srai t3, t2, ldsz, dataSize=asz376 lea t3, flatseg, [dsz, t3, base], dataSize=asz377 limm t4, 1378 rol t4, t4, reg379 mfence380 ldstl t1, seg, [1, t3, t7], disp381 sext t0, t1, reg, flags=(CF,)382 or t1, t1, t4383 stul t1, seg, [1, t3, t7], disp384 mfence385};...
test_return_real.py
Source:test_return_real.py
...46 module_name = "c_ext_return_real"47 code = """48python module c_ext_return_real49usercode \'\'\'50float t4(float value) { return value; }51void s4(float *t4, float value) { *t4 = value; }52double t8(double value) { return value; }53void s8(double *t8, double value) { *t8 = value; }54\'\'\'55interface56 function t4(value)57 real*4 intent(c) :: t4,value58 end59 function t8(value)60 real*8 intent(c) :: t8,value61 end62 subroutine s4(t4,value)63 intent(c) s464 real*4 intent(out) :: t465 real*4 intent(c) :: value66 end67 subroutine s8(t8,value)68 intent(c) s869 real*8 intent(out) :: t870 real*8 intent(c) :: value71 end72end interface73end python module c_ext_return_real74 """75 @pytest.mark.slow76 def test_all(self):77 for name in "t4,t8,s4,s8".split(","):78 self.check_function(getattr(self.module, name))79class TestF77ReturnReal(TestReturnReal):80 code = """81 function t0(value)82 real value83 real t084 t0 = value85 end86 function t4(value)87 real*4 value88 real*4 t489 t4 = value90 end91 function t8(value)92 real*8 value93 real*8 t894 t8 = value95 end96 function td(value)97 double precision value98 double precision td99 td = value100 end101 subroutine s0(t0,value)102 real value103 real t0104cf2py intent(out) t0105 t0 = value106 end107 subroutine s4(t4,value)108 real*4 value109 real*4 t4110cf2py intent(out) t4111 t4 = value112 end113 subroutine s8(t8,value)114 real*8 value115 real*8 t8116cf2py intent(out) t8117 t8 = value118 end119 subroutine sd(td,value)120 double precision value121 double precision td122cf2py intent(out) td123 td = value124 end125 """126 @pytest.mark.slow127 def test_all(self):128 for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):129 self.check_function(getattr(self.module, name))130class TestF90ReturnReal(TestReturnReal):131 suffix = ".f90"132 code = """133module f90_return_real134 contains135 function t0(value)136 real :: value137 real :: t0138 t0 = value139 end function t0140 function t4(value)141 real(kind=4) :: value142 real(kind=4) :: t4143 t4 = value144 end function t4145 function t8(value)146 real(kind=8) :: value147 real(kind=8) :: t8148 t8 = value149 end function t8150 function td(value)151 double precision :: value152 double precision :: td153 td = value154 end function td...
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!!