How to use TestBasic method of db Package

Best Syzkaller code snippet using db.TestBasic

objdump_test.go

Source:objdump_test.go Github

copy

Full Screen

1// Copyright 2014 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4package x86asm5import (6 "bytes"7 "strings"8 "testing"9)10func TestObjdump32Manual(t *testing.T) { testObjdump32(t, hexCases(t, objdumpManualTests)) }11func TestObjdump32Testdata(t *testing.T) { testObjdump32(t, concat(basicPrefixes, testdataCases(t))) }12func TestObjdump32ModRM(t *testing.T) { testObjdump32(t, concat(basicPrefixes, enumModRM)) }13func TestObjdump32OneByte(t *testing.T) { testBasic(t, testObjdump32) }14func TestObjdump320F(t *testing.T) { testBasic(t, testObjdump32, 0x0F) }15func TestObjdump320F38(t *testing.T) { testBasic(t, testObjdump32, 0x0F, 0x38) }16func TestObjdump320F3A(t *testing.T) { testBasic(t, testObjdump32, 0x0F, 0x3A) }17func TestObjdump32Prefix(t *testing.T) { testPrefix(t, testObjdump32) }18func TestObjdump64Manual(t *testing.T) { testObjdump64(t, hexCases(t, objdumpManualTests)) }19func TestObjdump64Testdata(t *testing.T) { testObjdump64(t, concat(basicPrefixes, testdataCases(t))) }20func TestObjdump64ModRM(t *testing.T) { testObjdump64(t, concat(basicPrefixes, enumModRM)) }21func TestObjdump64OneByte(t *testing.T) { testBasic(t, testObjdump64) }22func TestObjdump640F(t *testing.T) { testBasic(t, testObjdump64, 0x0F) }23func TestObjdump640F38(t *testing.T) { testBasic(t, testObjdump64, 0x0F, 0x38) }24func TestObjdump640F3A(t *testing.T) { testBasic(t, testObjdump64, 0x0F, 0x3A) }25func TestObjdump64Prefix(t *testing.T) { testPrefix(t, testObjdump64) }26func TestObjdump64REXTestdata(t *testing.T) {27 testObjdump64(t, filter(concat3(basicPrefixes, rexPrefixes, testdataCases(t)), isValidREX))28}29func TestObjdump64REXModRM(t *testing.T) {30 testObjdump64(t, concat3(basicPrefixes, rexPrefixes, enumModRM))31}32func TestObjdump64REXOneByte(t *testing.T) { testBasicREX(t, testObjdump64) }33func TestObjdump64REX0F(t *testing.T) { testBasicREX(t, testObjdump64, 0x0F) }34func TestObjdump64REX0F38(t *testing.T) { testBasicREX(t, testObjdump64, 0x0F, 0x38) }35func TestObjdump64REX0F3A(t *testing.T) { testBasicREX(t, testObjdump64, 0x0F, 0x3A) }36func TestObjdump64REXPrefix(t *testing.T) { testPrefixREX(t, testObjdump64) }37// objdumpManualTests holds test cases that will be run by TestObjdumpManual.38// If you are debugging a few cases that turned up in a longer run, it can be useful39// to list them here and then use -run=ObjdumpManual, particularly with tracing enabled.40var objdumpManualTests = `414883FE01741342488DFC250000000043488D3D0000000044`45// allowedMismatchObjdump reports whether the mismatch between text and dec46// should be allowed by the test.47func allowedMismatchObjdump(text string, size int, inst *Inst, dec ExtInst) bool {48 if size == 15 && dec.nenc == 15 && contains(text, "truncated") && contains(dec.text, "(bad)") {49 return true50 }51 if i := strings.LastIndex(dec.text, " "); isPrefix(dec.text[i+1:]) && size == 1 && isPrefix(text) {52 return true53 }54 if size == dec.nenc && contains(dec.text, "movupd") && contains(dec.text, "data32") {55 s := strings.Replace(dec.text, "data32 ", "", -1)56 if text == s {57 return true58 }59 }60 // Simplify our invalid instruction text.61 if text == "error: unrecognized instruction" {62 text = "BAD"63 }64 // Invalid instructions for which libopcodes prints %? register.65 // FF E8 11 22 33 44:66 // Invalid instructions for which libopcodes prints "internal disassembler error".67 // Invalid instructions for which libopcodes prints 8087 only (e.g., DB E0)68 // or prints 287 only (e.g., DB E4).69 if contains(dec.text, "%?", "<internal disassembler error>", "(8087 only)", "(287 only)") {70 dec.text = "(bad)"71 }72 // 0F 19 11, 0F 1C 11, 0F 1D 11, 0F 1E 11, 0F 1F 11: libopcodes says nop,73 // but the Intel manuals say that the only NOP there is 0F 1F /0.74 // Perhaps libopcodes is reporting an older encoding.75 i := bytes.IndexByte(dec.enc[:], 0x0F)76 if contains(dec.text, "nop") && i >= 0 && i+2 < len(dec.enc) && dec.enc[i+1]&^7 == 0x18 && (dec.enc[i+1] != 0x1F || (dec.enc[i+2]>>3)&7 != 0) {77 dec.text = "(bad)"78 }79 // Any invalid instruction.80 if text == "BAD" && contains(dec.text, "(bad)") {81 return true82 }83 // Instructions libopcodes knows but we do not (e.g., 0F 19 11).84 if (text == "BAD" || size == 1 && isPrefix(text)) && hasPrefix(dec.text, unsupported...) {85 return true86 }87 // Instructions we know but libopcodes does not (e.g., 0F D0 11).88 if (contains(dec.text, "(bad)") || dec.nenc == 1 && isPrefix(dec.text)) && hasPrefix(text, libopcodesUnsupported...) {89 return true90 }91 // Libopcodes rejects F2 90 as NOP. Not sure why.92 if (contains(dec.text, "(bad)") || dec.nenc == 1 && isPrefix(dec.text)) && inst.Opcode>>24 == 0x90 && countPrefix(inst, 0xF2) > 0 {93 return true94 }95 // 0F 20 11, 0F 21 11, 0F 22 11, 0F 23 11, 0F 24 11:96 // Moves into and out of some control registers seem to be unsupported by libopcodes.97 // TODO(rsc): Are they invalid somehow?98 if (contains(dec.text, "(bad)") || dec.nenc == 1 && isPrefix(dec.text)) && contains(text, "%cr", "%db", "%tr") {99 return true100 }101 if contains(dec.text, "fwait") && dec.nenc == 1 && dec.enc[0] != 0x9B {102 return true103 }104 // 9B D9 11: libopcodes reports FSTSW instead of FWAIT + FNSTSW.105 // This is correct in that FSTSW is a pseudo-op for the pair, but it really106 // is a pair of instructions: execution can stop between them.107 // Our decoder chooses to separate them.108 if (text == "fwait" || strings.HasSuffix(text, " fwait")) && dec.nenc >= len(strings.Fields(text)) && dec.enc[len(strings.Fields(text))-1] == 0x9B {109 return true110 }111 // 0F 18 77 11:112 // Invalid instructions for which libopcodes prints "nop/reserved".113 // Perhaps libopcodes is reporting an older encoding.114 if text == "BAD" && contains(dec.text, "nop/reserved") {115 return true116 }117 // 0F C7 B0 11 22 33 44: libopcodes says vmptrld 0x44332211(%eax); we say rdrand %eax.118 // TODO(rsc): Fix, since we are probably wrong, but we don't have vmptrld in the manual.119 if contains(text, "rdrand") && contains(dec.text, "vmptrld", "vmxon", "vmclear") {120 return true121 }122 // DD C8: libopcodes says FNOP but the Intel manual is clear FNOP is only D9 D0.123 // Perhaps libopcodes is reporting an older encoding.124 if text == "BAD" && contains(dec.text, "fnop") && (dec.enc[0] != 0xD9 || dec.enc[1] != 0xD0) {125 return true126 }127 // 66 90: libopcodes says xchg %ax,%ax; we say 'data16 nop'.128 // The 16-bit swap will preserve the high bits of the register,129 // so they are the same.130 if contains(text, "nop") && contains(dec.text, "xchg %ax,%ax") {131 return true132 }133 // If there are multiple prefixes, allow libopcodes to use an alternate name.134 if size == 1 && dec.nenc == 1 && prefixByte[text] > 0 && prefixByte[text] == prefixByte[dec.text] {135 return true136 }137 // 26 9B: libopcodes reports "fwait"/1, ignoring segment prefix.138 // https://sourceware.org/bugzilla/show_bug.cgi?id=16891139 // F0 82: Decode="lock"/1 but libopcodes="lock (bad)"/2.140 if size == 1 && dec.nenc >= 1 && prefixByte[text] == dec.enc[0] && contains(dec.text, "(bad)", "fwait", "fnop") {141 return true142 }143 // libopcodes interprets 660f801122 as taking a rel16 but144 // truncating the address at 16 bits. Not sure what is correct.145 if contains(text, ".+0x2211", ".+0x11") && contains(dec.text, " .-") {146 return true147 }148 // 66 F3 0F D6 C5, 66 F2 0F D6 C0: libopcodes reports use of XMM register instead of MMX register,149 // but only when the instruction has a 66 prefix. Maybe they know something we don't.150 if countPrefix(inst, 0x66) > 0 && contains(dec.text, "movdq2q", "movq2dq") && !contains(dec.text, "%mm") {151 return true152 }153 // 0F 01 F8, 0F 05, 0F 07: these are 64-bit instructions but libopcodes accepts them.154 if (text == "BAD" || size == 1 && isPrefix(text)) && contains(dec.text, "swapgs", "syscall", "sysret", "rdfsbase", "rdgsbase", "wrfsbase", "wrgsbase") {155 return true156 }157 return false158}159// Instructions known to libopcodes (or xed) but not to us.160// Most of these come from supplementary manuals of one form or another.161var unsupported = strings.Fields(`162 bndc163 bndl164 bndm165 bnds166 clac167 clgi168 femms169 fldln170 fldz171 getsec172 invlpga173 kmov174 montmul175 pavg176 pf2i177 pfacc178 pfadd179 pfcmp180 pfmax181 pfmin182 pfmul183 pfna184 pfpnac185 pfrc186 pfrs187 pfsub188 phadd189 phsub190 pi2f191 pmulhr192 prefetch193 pswap194 ptest195 rdseed196 sha1197 sha256198 skinit199 stac200 stgi201 vadd202 vand203 vcmp204 vcomis205 vcvt206 vcvt207 vdiv208 vhadd209 vhsub210 vld211 vmax212 vmcall213 vmfunc214 vmin215 vmlaunch216 vmload217 vmmcall218 vmov219 vmov220 vmov221 vmptrld222 vmptrst223 vmread224 vmresume225 vmrun226 vmsave227 vmul228 vmwrite229 vmxoff230 vor231 vpack232 vpadd233 vpand234 vpavg235 vpcmp236 vpcmp237 vpins238 vpmadd239 vpmax240 vpmin241 vpmul242 vpmul243 vpor244 vpsad245 vpshuf246 vpsll247 vpsra248 vpsrad249 vpsrl250 vpsub251 vpunp252 vpxor253 vrcp254 vrsqrt255 vshuf256 vsqrt257 vsub258 vucomis259 vunp260 vxor261 vzero262 xcrypt263 xsha1264 xsha256265 xstore-rng266 insertq267 extrq268 vmclear269 invvpid270 adox271 vmxon272 invept273 adcx274 vmclear275 prefetchwt1276 enclu277 encls278 salc279 fstpnce280 fdisi8087_nop281 fsetpm287_nop282 feni8087_nop283 syscall284 sysret285`)286// Instructions known to us but not to libopcodes (at least in binutils 2.24).287var libopcodesUnsupported = strings.Fields(`288 addsubps289 aes290 blend291 cvttpd2dq292 dpp293 extract294 haddps295 hsubps296 insert297 invpcid298 lddqu299 movmsk300 movnt301 movq2dq302 mps303 pack304 pblend305 pclmul306 pcmp307 pext308 phmin309 pins310 pmax311 pmin312 pmov313 pmovmsk314 pmul315 popcnt316 pslld317 psllq318 psllw319 psrad320 psraw321 psrl322 ptest323 punpck324 round325 xrstor326 xsavec327 xsaves328 comis329 ucomis330 movhps331 movntps332 rsqrt333 rcpp334 puncpck335 bsf336 movq2dq337 cvttpd2dq338 movq339 hsubpd340 movdqa341 movhpd342 addsubpd343 movd344 haddpd345 cvtps2dq346 bsr347 cvtdq2ps348 rdrand349 maskmov350 movq2dq351 movlhps352 movbe353 movlpd354`)...

Full Screen

Full Screen

TestBasic

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 db, err := sql.Open("mysql", "root:root@/test")4 if err != nil {5 fmt.Println(err)6 }7 defer db.Close()8 err = db.Ping()9 if err != nil {10 fmt.Println(err)11 }12 rows, err := db.Query("select id, name from test")13 if err != nil {14 fmt.Println(err)15 }16 defer rows.Close()17 for rows.Next() {18 err := rows.Scan(&id, &name)19 if err != nil {20 fmt.Println(err)21 }22 fmt.Println(id, name)23 }24 err = rows.Err()25 if err != nil {26 fmt.Println(err)27 }28}

Full Screen

Full Screen

TestBasic

Using AI Code Generation

copy

Full Screen

1import (2type db struct {3}4func (db *db) TestBasic() {5 fmt.Println("TestBasic")6}7func main() {8 fmt.Println("Hello, playground")9 db := db{}10 db.TestBasic()11}12import (13type db struct {14}15func (db *db) TestBasic() {16 fmt.Println("TestBasic")17}18func main() {19 fmt.Println("Hello, playground")20 db := db{}21 db.TestBasic()22}23import (24type db struct {25}26func (db *db) TestBasic() {27 fmt.Println("TestBasic")28}29func main() {30 fmt.Println("Hello, playground")31 db := db{}32 db.TestBasic()33}34import (35type db struct {36}37func (db *db) TestBasic() {38 fmt.Println("TestBasic")39}40func main() {41 fmt.Println("Hello, playground")42 db := db{}43 db.TestBasic()44}45import (46type db struct {47}48func (db *db) TestBasic() {49 fmt.Println("TestBasic")50}51func main() {52 fmt.Println("Hello, playground")53 db := db{}54 db.TestBasic()55}56import (

Full Screen

Full Screen

TestBasic

Using AI Code Generation

copy

Full Screen

1import (2var (3 LogFile = golenv.OverrideIfEnv("LOG_FILE", "/tmp/go.log")4 HTTPPort = golenv.OverrideIfEnv("HTTP_PORT", "8080")5 OSName = golenv.OverrideIfEnv("OS_NAME", "linux")6 Str = golenv.OverrideIfEnv("STR", "AbhishekKr")7 Time = golenv.OverrideIfEnv("TIME", "2014-07-01 23:00:00")8func main() {9 gollog.Config(LogFile)10 gollog.Logln("Starting GoLang Server")11 http.HandleFunc("/", handler)12 http.ListenAndServe(":"+HTTPPort, nil)13}14func handler(w http.ResponseWriter, r *http.Request) {15 var (16 gollog_msg = gollog.Logln("gollog.Logln()")17 golos_msg = golos.Os(OSName)18 golstring_msg = golstring.Reverse(Str)19 goltime_msg = goltime.Time(Time)20 golweb_msg = golweb.Url(WebURL)21 fmt.Fprintf(w, gollog_msg, golos_msg, golstring_msg, goltime_msg, golweb_msg)22}23import (

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful