How to use Info method of powerpc Package

Best Syzkaller code snippet using powerpc.Info

elf.go

Source:elf.go Github

copy

Full Screen

...2244 Addr uint32 /* Address in memory image. */2245 Off uint32 /* Offset in file. */2246 Size uint32 /* Size in bytes. */2247 Link uint32 /* Index of a related section. */2248 Info uint32 /* Depends on section type. */2249 Addralign uint32 /* Alignment in bytes. */2250 Entsize uint32 /* Size of each entry in section. */2251}2252// ELF32 Program header.2253type Prog32 struct {2254 Type uint32 /* Entry type. */2255 Off uint32 /* File offset of contents. */2256 Vaddr uint32 /* Virtual address in memory image. */2257 Paddr uint32 /* Physical address (not used). */2258 Filesz uint32 /* Size of contents in file. */2259 Memsz uint32 /* Size of contents in memory. */2260 Flags uint32 /* Access permission flags. */2261 Align uint32 /* Alignment in memory and file. */2262}2263// ELF32 Dynamic structure. The ".dynamic" section contains an array of them.2264type Dyn32 struct {2265 Tag int32 /* Entry type. */2266 Val uint32 /* Integer/Address value. */2267}2268// ELF32 Compression header.2269type Chdr32 struct {2270 Type uint322271 Size uint322272 Addralign uint322273}2274/*2275 * Relocation entries.2276 */2277// ELF32 Relocations that don't need an addend field.2278type Rel32 struct {2279 Off uint32 /* Location to be relocated. */2280 Info uint32 /* Relocation type and symbol index. */2281}2282// ELF32 Relocations that need an addend field.2283type Rela32 struct {2284 Off uint32 /* Location to be relocated. */2285 Info uint32 /* Relocation type and symbol index. */2286 Addend int32 /* Addend. */2287}2288func R_SYM32(info uint32) uint32 { return info >> 8 }2289func R_TYPE32(info uint32) uint32 { return info & 0xff }2290func R_INFO32(sym, typ uint32) uint32 { return sym<<8 | typ }2291// ELF32 Symbol.2292type Sym32 struct {2293 Name uint322294 Value uint322295 Size uint322296 Info uint82297 Other uint82298 Shndx uint162299}2300const Sym32Size = 162301func ST_BIND(info uint8) SymBind { return SymBind(info >> 4) }2302func ST_TYPE(info uint8) SymType { return SymType(info & 0xF) }2303func ST_INFO(bind SymBind, typ SymType) uint8 {2304 return uint8(bind)<<4 | uint8(typ)&0xf2305}2306func ST_VISIBILITY(other uint8) SymVis { return SymVis(other & 3) }2307/*2308 * ELF642309 */2310// ELF64 file header.2311type Header64 struct {2312 Ident [EI_NIDENT]byte /* File identification. */2313 Type uint16 /* File type. */2314 Machine uint16 /* Machine architecture. */2315 Version uint32 /* ELF format version. */2316 Entry uint64 /* Entry point. */2317 Phoff uint64 /* Program header file offset. */2318 Shoff uint64 /* Section header file offset. */2319 Flags uint32 /* Architecture-specific flags. */2320 Ehsize uint16 /* Size of ELF header in bytes. */2321 Phentsize uint16 /* Size of program header entry. */2322 Phnum uint16 /* Number of program header entries. */2323 Shentsize uint16 /* Size of section header entry. */2324 Shnum uint16 /* Number of section header entries. */2325 Shstrndx uint16 /* Section name strings section. */2326}2327// ELF64 Section header.2328type Section64 struct {2329 Name uint32 /* Section name (index into the section header string table). */2330 Type uint32 /* Section type. */2331 Flags uint64 /* Section flags. */2332 Addr uint64 /* Address in memory image. */2333 Off uint64 /* Offset in file. */2334 Size uint64 /* Size in bytes. */2335 Link uint32 /* Index of a related section. */2336 Info uint32 /* Depends on section type. */2337 Addralign uint64 /* Alignment in bytes. */2338 Entsize uint64 /* Size of each entry in section. */2339}2340// ELF64 Program header.2341type Prog64 struct {2342 Type uint32 /* Entry type. */2343 Flags uint32 /* Access permission flags. */2344 Off uint64 /* File offset of contents. */2345 Vaddr uint64 /* Virtual address in memory image. */2346 Paddr uint64 /* Physical address (not used). */2347 Filesz uint64 /* Size of contents in file. */2348 Memsz uint64 /* Size of contents in memory. */2349 Align uint64 /* Alignment in memory and file. */2350}2351// ELF64 Dynamic structure. The ".dynamic" section contains an array of them.2352type Dyn64 struct {2353 Tag int64 /* Entry type. */2354 Val uint64 /* Integer/address value */2355}2356// ELF64 Compression header.2357type Chdr64 struct {2358 Type uint322359 _ uint32 /* Reserved. */2360 Size uint642361 Addralign uint642362}2363/*2364 * Relocation entries.2365 */2366/* ELF64 relocations that don't need an addend field. */2367type Rel64 struct {2368 Off uint64 /* Location to be relocated. */2369 Info uint64 /* Relocation type and symbol index. */2370}2371/* ELF64 relocations that need an addend field. */2372type Rela64 struct {2373 Off uint64 /* Location to be relocated. */2374 Info uint64 /* Relocation type and symbol index. */2375 Addend int64 /* Addend. */2376}2377func R_SYM64(info uint64) uint32 { return uint32(info >> 32) }2378func R_TYPE64(info uint64) uint32 { return uint32(info) }2379func R_INFO(sym, typ uint32) uint64 { return uint64(sym)<<32 | uint64(typ) }2380// ELF64 symbol table entries.2381type Sym64 struct {2382 Name uint32 /* String table index of name. */2383 Info uint8 /* Type and binding information. */2384 Other uint8 /* Reserved (not used). */2385 Shndx uint16 /* Section index of symbol. */2386 Value uint64 /* Symbol value. */2387 Size uint64 /* Size of associated object. */2388}2389const Sym64Size = 242390type intName struct {2391 i uint322392 s string2393}2394func stringName(i uint32, names []intName, goSyntax bool) string {2395 for _, n := range names {2396 if n.i == i {2397 if goSyntax {...

Full Screen

Full Screen

deckbuilder_test.go

Source:deckbuilder_test.go Github

copy

Full Screen

...12// HELPERS13func checkCard(t *testing.T, i int, exp, act *core.Card) {14 checkDisplay(t, i, exp, act)15 // TODO: fix16 checkInfo(t, i, &exp.Info, &act.Info)17}18func checkDisplay(t *testing.T, i int, exp, act *core.Card) {19 test.ExpectEQ(t, exp.Data["Word"], act.Data["Word"], "card %d: Word match", i)20 test.ExpectEQ(t, exp.Data["Desc"], act.Data["Desc"], "card %d: Desc match", i)21 test.ExpectEQ(t, exp.Data["Hint"], act.Data["Hint"], "card %d: Hint match", i)22 test.ExpectEQ(t, exp.Data["Comp"], act.Data["Comp"], "card %d: Comp match", i)23 test.ExpectEQ(t, exp.Data["Image"], act.Data["Image"], "card %d: Image match", i)24}25func checkInfo(t *testing.T, i int, exp, act *core.Info) {26 test.ExpectEQ(t, exp.Set, act.Set, "card %d: Set match", i)27 test.ExpectEQ(t, exp.File, act.File, "card %d: Filenames match", i)28 test.ExpectEQ(t, exp.Tmpl, act.Tmpl, "card %d: Tmpl match", i)29 test.ExpectEQ(t, exp.Count, act.Count, "card %d: Count match", i)30 test.ExpectEQ(t, exp.Bucket, act.Bucket, "card %d: Bucket match", i)31}32// TESTS33func TestLoadDeck_Specific(t *testing.T) {34 usingTestdir(t, testdir, func() {35 testdata := []*core.Card{36 &core.Card{37 Data: map[string]string{38 "Word": "add.",39 "Image": "add.jpg",40 "Desc": "add. desc",41 "Hint": "add. hint",42 "Comp": "PowerPC instruction",43 },44 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "thisdoesx", Count: 7, Bucket: 0},45 },46 &core.Card{47 Data: map[string]string{48 "Word": "add.",49 "Image": "add.jpg",50 "Desc": "add. desc",51 "Hint": "add. hint",52 "Comp": "PowerPC instruction",53 },54 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "xdoesthis", Count: 3, Bucket: 1},55 },56 &core.Card{57 Data: map[string]string{58 "Word": "branch",59 "Image": "branch.jpg",60 "Desc": "branch desc",61 "Hint": "branch hint",62 "Comp": "PowerPC instruction",63 },64 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "thisdoesx", Count: 1, Bucket: 2},65 },66 &core.Card{67 Data: map[string]string{68 "Word": "branch",69 "Image": "branch.jpg",70 "Desc": "branch desc",71 "Hint": "branch hint",72 "Comp": "PowerPC instruction",73 },74 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},75 },76 }77 // just load 'ppc' deck78 deck, err := New(79 dir(testdir.name),80 Deck("ppc"),81 ).LoadDeck()82 test.Assert(t, err == nil, "unexpected error: %v", err)83 test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")84 i := 085 for _, b := range deck {86 for _, c := range b {87 checkCard(t, i, testdata[i], c)88 i++89 }90 }91 })92}93func TestMultipleDecksCanBeLoaded(t *testing.T) {94 usingTestdir(t, testdir, func() {95 testdata := []*core.Card{96 &core.Card{97 Data: map[string]string{98 "Word": "push",99 "Image": "push.jpg",100 "Desc": "push desc",101 "Hint": "push hint",102 "Comp": "git command",103 },104 Info: core.Info{Set: "git", File: "push.data", Tmpl: "thisdoesx", Count: 2, Bucket: 0},105 },106 &core.Card{107 Data: map[string]string{108 "Word": "add.",109 "Image": "add.jpg",110 "Desc": "add. desc",111 "Hint": "add. hint",112 "Comp": "PowerPC instruction",113 },114 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "thisdoesx", Count: 7, Bucket: 0},115 },116 &core.Card{117 Data: map[string]string{118 "Word": "push",119 "Image": "push.jpg",120 "Desc": "push desc",121 "Hint": "push hint",122 "Comp": "git command",123 },124 Info: core.Info{Set: "git", File: "push.data", Tmpl: "xdoesthis", Count: 1, Bucket: 1},125 },126 &core.Card{127 Data: map[string]string{128 "Word": "add.",129 "Image": "add.jpg",130 "Desc": "add. desc",131 "Hint": "add. hint",132 "Comp": "PowerPC instruction",133 },134 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "xdoesthis", Count: 3, Bucket: 1},135 },136 &core.Card{137 Data: map[string]string{138 "Word": "commit",139 "Image": "commit.jpg",140 "Desc": "commit desc",141 "Hint": "commit hint",142 "Comp": "git command",143 },144 Info: core.Info{Set: "git", File: "commit.data", Tmpl: "thisdoesx", Count: 0, Bucket: 2},145 },146 &core.Card{147 Data: map[string]string{148 "Word": "branch",149 "Image": "branch.jpg",150 "Desc": "branch desc",151 "Hint": "branch hint",152 "Comp": "PowerPC instruction",153 },154 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "thisdoesx", Count: 1, Bucket: 2},155 },156 &core.Card{157 Data: map[string]string{158 "Word": "commit",159 "Image": "commit.jpg",160 "Desc": "commit desc",161 "Hint": "commit hint",162 "Comp": "git command",163 },164 Info: core.Info{Set: "git", File: "commit.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},165 },166 &core.Card{167 Data: map[string]string{168 "Word": "branch",169 "Image": "branch.jpg",170 "Desc": "branch desc",171 "Hint": "branch hint",172 "Comp": "PowerPC instruction",173 },174 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},175 },176 }177 deck, err := New(178 dir(testdir.name),179 ).LoadDeck()180 test.Assert(t, err == nil, "unexpected error: %v", err)181 test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")182 i := 0183 for _, b := range deck {184 for _, c := range b {185 checkCard(t, i, testdata[i], c)186 i++187 }188 }189 })190}191func TestLoadDeck_SubPathDecksMustHaveSpecificNames(t *testing.T) {192 usingTestdir(t, nestedTestdir, func() {193 // just load 'ppc' deck194 _, err := New(195 dir(nestedTestdir.name),196 Deck("ppc"),197 ).LoadDeck()198 test.Expect(t, err != nil, "didn't recieve expected error")199 })200}201func TestLoadDeck_DecksCanHaveSubPaths(t *testing.T) {202 usingTestdir(t, nestedTestdir, func() {203 testdata := []*core.Card{204 &core.Card{205 Data: map[string]string{206 "Word": "add.",207 "Image": "add.jpg",208 "Desc": "add. desc",209 "Hint": "add. hint",210 "Comp": "PowerPC instruction",211 },212 Info: core.Info{Set: "facts/ppc", File: "add..data", Tmpl: "thisdoesx", Count: 7, Bucket: 0},213 },214 &core.Card{215 Data: map[string]string{216 "Word": "add.",217 "Image": "add.jpg",218 "Desc": "add. desc",219 "Hint": "add. hint",220 "Comp": "PowerPC instruction",221 },222 Info: core.Info{Set: "facts/ppc", File: "add..data", Tmpl: "xdoesthis", Count: 3, Bucket: 1},223 },224 &core.Card{225 Data: map[string]string{226 "Word": "branch",227 "Image": "branch.jpg",228 "Desc": "branch desc",229 "Hint": "branch hint",230 "Comp": "PowerPC instruction",231 },232 Info: core.Info{Set: "facts/ppc", File: "branch.data", Tmpl: "thisdoesx", Count: 1, Bucket: 2},233 },234 &core.Card{235 Data: map[string]string{236 "Word": "branch",237 "Image": "branch.jpg",238 "Desc": "branch desc",239 "Hint": "branch hint",240 "Comp": "PowerPC instruction",241 },242 Info: core.Info{Set: "facts/ppc", File: "branch.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},243 },244 }245 // load 'facts/ppc' deck246 deck, err := New(247 dir(nestedTestdir.name),248 Deck("facts/ppc"),249 ).LoadDeck()250 test.Assert(t, err == nil, "unexpected error: %v", err)251 test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")252 i := 0253 for _, b := range deck {254 for _, c := range b {255 checkCard(t, i, testdata[i], c)256 i++257 }258 }259 })260}261func TestLoadDeck_SubPaths_All(t *testing.T) {262 usingTestdir(t, nestedTestdir, func() {263 testdata := []*core.Card{264 &core.Card{265 Data: map[string]string{266 "Word": "add.",267 "Image": "add.jpg",268 "Desc": "add. desc",269 "Hint": "add. hint",270 "Comp": "PowerPC instruction",271 },272 Info: core.Info{Set: "facts/ppc", File: "add..data", Tmpl: "thisdoesx", Count: 7, Bucket: 0},273 },274 &core.Card{275 Data: map[string]string{276 "Word": "add.",277 "Image": "add.jpg",278 "Desc": "add. desc",279 "Hint": "add. hint",280 "Comp": "PowerPC instruction",281 },282 Info: core.Info{Set: "facts/ppc", File: "add..data", Tmpl: "xdoesthis", Count: 3, Bucket: 1},283 },284 &core.Card{285 Data: map[string]string{286 "Word": "branch",287 "Image": "branch.jpg",288 "Desc": "branch desc",289 "Hint": "branch hint",290 "Comp": "PowerPC instruction",291 },292 Info: core.Info{Set: "facts/ppc", File: "branch.data", Tmpl: "thisdoesx", Count: 1, Bucket: 2},293 },294 &core.Card{295 Data: map[string]string{296 "Word": "branch",297 "Image": "branch.jpg",298 "Desc": "branch desc",299 "Hint": "branch hint",300 "Comp": "PowerPC instruction",301 },302 Info: core.Info{Set: "facts/ppc", File: "branch.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},303 },304 }305 // load 'facts/ppc' deck306 deck, err := New(307 dir(nestedTestdir.name),308 ).LoadDeck()309 test.Assert(t, err == nil, "unexpected error: %v", err)310 test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")311 i := 0312 for _, b := range deck {313 for _, c := range b {314 checkCard(t, i, testdata[i], c)315 i++316 }317 }318 })319}320func TestLoadDeck_DecksCanBeExcludedFromLoading(t *testing.T) {321 usingTestdir(t, testdir, func() {322 testdata := []*core.Card{323 &core.Card{324 Data: map[string]string{325 "Word": "add.",326 "Image": "add.jpg",327 "Desc": "add. desc",328 "Hint": "add. hint",329 "Comp": "PowerPC instruction",330 },331 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "thisdoesx", Count: 7, Bucket: 0},332 },333 &core.Card{334 Data: map[string]string{335 "Word": "add.",336 "Image": "add.jpg",337 "Desc": "add. desc",338 "Hint": "add. hint",339 "Comp": "PowerPC instruction",340 },341 Info: core.Info{Set: "ppc", File: "add..data", Tmpl: "xdoesthis", Count: 3, Bucket: 1},342 },343 &core.Card{344 Data: map[string]string{345 "Word": "branch",346 "Image": "branch.jpg",347 "Desc": "branch desc",348 "Hint": "branch hint",349 "Comp": "PowerPC instruction",350 },351 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "thisdoesx", Count: 1, Bucket: 2},352 },353 &core.Card{354 Data: map[string]string{355 "Word": "branch",356 "Image": "branch.jpg",357 "Desc": "branch desc",358 "Hint": "branch hint",359 "Comp": "PowerPC instruction",360 },361 Info: core.Info{Set: "ppc", File: "branch.data", Tmpl: "xdoesthis", Count: 0, Bucket: 3},362 },363 }364 deck, err := New(365 Exclude("git"),366 dir(testdir.name),367 ).LoadDeck()368 test.Assert(t, err == nil, "unexpected error: %v", err)369 test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")370 i := 0371 for _, b := range deck {372 for _, c := range b {373 checkCard(t, i, testdata[i], c)374 i++375 }376 }377 })378}379func TestLoadDeck_DirsCanBeExcludedFromLoading(t *testing.T) {380 usingTestdir(t, nestedTestdir, func() {381 deck, err := New(382 Exclude("facts/"),383 dir(testdir.name),384 ).LoadDeck()385 test.Assert(t, err == nil, "unexpected error: %v", err)386 // test.AssertEQ(t, len(testdata), deck.Count(), "wrong number of cards loaded")387 // TODO: remove this when we get Deck.Length()388 i := 0389 for _, b := range deck {390 for _ = range b {391 i++392 }393 }394 test.Assert(t, i == 0, "No cards loaded")395 })396}397func TestLoadDeck_Error(t *testing.T) {398 usingTestdir(t, testdir, func() {399 deck, err := New(400 dir(testdir.name),401 Deck("DoesNotExist"),402 ).LoadDeck()403 test.Assert(t, err != nil, "expected error")404 test.Expect(t, nil == deck, "deck should be empty")405 })406}407func Test_getDeckInfo(t *testing.T) {408 // set up test409 err := os.Mkdir("tmp", 0770)410 test.Assert(t, err == nil, "Mkdir: %v", err)411 f, err := ioutil.TempFile("tmp", "temp")412 test.Assert(t, err == nil, "TempFile: %v", err)413 // clean up414 defer func() {415 f.Close()416 if err := os.RemoveAll("tmp"); err != nil {417 t.Errorf("remove: %v", err)418 }419 }()420 json := []byte(`421 {422 "Display": "my-display",423 "Info": [424 {425 "File": "add.",426 "Tmpl": "thisdoesx",427 "Count": 0,428 "Bucket": 3,429 "FirstSeen": "0001-01-01T00:00:00Z",430 "LastSeen": "0001-01-01T00:00:00Z"431 },432 {433 "File": "add.",434 "Tmpl": "xdoesthis",435 "Count": 2,436 "Bucket": 1,437 "FirstSeen": "0001-01-01T00:00:00Z",438 "LastSeen": "0001-01-01T00:00:00Z"439 }440 ]441 }442 `)443 _, err = f.Write(json)444 test.Assert(t, err == nil, "Write: %v", err)445 exp := deckInfo{446 Display: "my-display",447 Info: []*core.Info{448 &core.Info{File: "add.", Tmpl: "thisdoesx", Count: 0, Bucket: core.Yearly},449 &core.Info{File: "add.", Tmpl: "xdoesthis", Count: 2, Bucket: core.Weekly},450 },451 }452 di, err := getDeckInfo(f.Name())453 test.Assert(t, err == nil, "getDeckInfo: %v", err)454 test.ExpectEQ(t, exp.Display, di.Display, "display not read-in properly")455 test.Assert(t, len(di.Info) == 2, "info not read-in properly")456 checkInfo(t, 0, exp.Info[0], di.Info[0])457 checkInfo(t, 1, exp.Info[1], di.Info[1])458}459func Test_getCardDataFromDisk(t *testing.T) {460 usingTestdir(t, testdir, func() {461 testdata := []CardHolder{462 {463 File: "add..data",464 Card: &core.Card{465 Data: map[string]string{466 "Word": "add.",467 "Image": "add.jpg",468 "Desc": "add. desc",469 "Hint": "add. hint",470 "Comp": "PowerPC instruction",471 },472 },473 },474 {475 File: "branch.data",476 Card: &core.Card{477 Data: map[string]string{478 "Word": "branch",479 "Image": "branch.jpg",480 "Desc": "branch desc",481 "Hint": "branch hint",482 "Comp": "PowerPC instruction",483 },484 },485 },486 }487 path := testdir.name + "/html/decks/ppc/cards"488 data, err := getCardDataFromDisk(path, "basic")489 test.Assert(t, err == nil, "getDataFromDisk: %v", err)490 test.Assert(t, len(data) == len(testdata), "data length mismatch")491 for i, exp := range testdata {492 checkDisplay(t, i, exp.Card, data[i].Card)493 }494 })495}496// func Test_makeCards(t *testing.T) {497// testdata := []struct {498// data []core.Display499// info []*core.Info500// exp []*core.Card501// }{502// // old and new match503// {504// data: []core.Display{505// &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},506// &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},507// },508// info: []*core.Info{509// core.Info{Set: "ppc", File: "add.", Tmpl: "thisdoesx", Count: 7, Bucket: 0},510// core.Info{Set: "ppc", File: "add.", Tmpl: "xdoesthis", Count: 3, Bucket: 1},511// core.Info{Set: "ppc", File: "branch", Tmpl: "thisdoesx", Count: 1, Bucket: 2},512// core.Info{Set: "ppc", File: "branch", Tmpl: "xdoesthis", Count: 0, Bucket: 3},513// },514// exp: []*core.Card{515// &core.Card{516// Display: &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},517// Info: core.Info{Set: "ppc", File: "add.", Tmpl: "thisdoesx", Count: 7, Bucket: 0},518// },519// &core.Card{520// Display: &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},521// Info: core.Info{Set: "ppc", File: "add.", Tmpl: "xdoesthis", Count: 3, Bucket: 1},522// },523// &core.Card{524// Display: &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},525// Info: core.Info{Set: "ppc", File: "branch", Tmpl: "thisdoesx", Count: 1, Bucket: 2},526// },527// &core.Card{528// Display: &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},529// Info: core.Info{Set: "ppc", File: "branch", Tmpl: "xdoesthis", Count: 0, Bucket: 3},530// },531// },532// },533// // deleted 'branch'534// {535// data: []core.Display{536// &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},537// },538// info: []*core.Info{539// core.Info{Set: "ppc", File: "add.", Tmpl: "thisdoesx", Count: 7, Bucket: 0},540// core.Info{Set: "ppc", File: "add.", Tmpl: "xdoesthis", Count: 3, Bucket: 1},541// core.Info{Set: "ppc", File: "branch", Tmpl: "thisdoesx", Count: 1, Bucket: 2},542// core.Info{Set: "ppc", File: "branch", Tmpl: "xdoesthis", Count: 0, Bucket: 3},543// },544// exp: []*core.Card{545// &core.Card{546// Display: &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},547// Info: core.Info{Set: "ppc", File: "add.", Tmpl: "thisdoesx", Count: 7, Bucket: 0},548// },549// &core.Card{550// Display: &basic.Display{Word: "add.", Image: "add.jpg", Desc: "add. desc", Hint: "add. hint", Comp: "PowerPC instruction"},551// Info: core.Info{Set: "ppc", File: "add.", Tmpl: "xdoesthis", Count: 3, Bucket: 1},552// },553// },554// },555// // add push.556// {557// data: []core.Display{558// &basic.Display{Word: "cmp", Image: "cmp.jpg", Desc: "cmp desc", Hint: "cmp hint", Comp: "PowerPC instruction"},559// &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},560// },561// info: []*core.Info{562// core.Info{Set: "ppc", File: "branch", Tmpl: "thisdoesx", Count: 1, Bucket: 2},563// core.Info{Set: "ppc", File: "branch", Tmpl: "xdoesthis", Count: 0, Bucket: 3},564// },565// exp: []*core.Card{566// &core.Card{567// Display: &basic.Display{Word: "cmp", Image: "cmp.jpg", Desc: "cmp desc", Hint: "cmp hint", Comp: "PowerPC instruction"},568// Info: core.Info{Set: "ppc", File: "cmp", Tmpl: "thisdoesx", Count: 0, Bucket: 0},569// },570// &core.Card{571// Display: &basic.Display{Word: "cmp", Image: "cmp.jpg", Desc: "cmp desc", Hint: "cmp hint", Comp: "PowerPC instruction"},572// Info: core.Info{Set: "ppc", File: "cmp", Tmpl: "xdoesthis", Count: 0, Bucket: 0},573// },574// &core.Card{575// Display: &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},576// Info: core.Info{Set: "ppc", File: "branch", Tmpl: "thisdoesx", Count: 1, Bucket: 2},577// },578// &core.Card{579// Display: &basic.Display{Word: "branch", Image: "branch.jpg", Desc: "branch desc", Hint: "branch hint", Comp: "PowerPC instruction"},580// Info: core.Info{Set: "ppc", File: "branch", Tmpl: "xdoesthis", Count: 0, Bucket: 3},581// },582// },583// },584// }585// for i, tt := range testdata {586// cards := makeCards("ppc", tt.info, tt.data)587// if len(tt.exp) != len(cards) {588// for _, c := range cards {589// fmt.Println(c)590// }591// }592// test.AssertEQ(t, len(tt.exp), len(cards), fmt.Sprintf("len mismatch, test %v", i))593// for j := range tt.exp {594// checkCard(t, i*j+j, tt.exp[i], cards[i])595// }596// }597// }598// func Test_updateBuckets(t *testing.T) {599// testdata := []struct {600// in, exp []*core.Card601// }{602// {603// in: []*core.Card{604// &core.Card{Info: core.Info{Count: 8, Bucket: 0}},605// &core.Card{Info: core.Info{Count: 4, Bucket: 1}},606// &core.Card{Info: core.Info{Count: 1, Bucket: 2}},607// &core.Card{Info: core.Info{Count: -1, Bucket: 3}},608// },609// exp: []*core.Card{610// &core.Card{Info: core.Info{Count: 0, Bucket: 1}},611// &core.Card{Info: core.Info{Count: 0, Bucket: 2}},612// &core.Card{Info: core.Info{Count: 1, Bucket: 2}},613// &core.Card{Info: core.Info{Count: 0, Bucket: 2}},614// },615// },616// }617// for i, tt := range testdata {618// act := updateBuckets(tt.in)619// for j := range tt.exp {620// checkInfo(t, i*j+j, tt.exp[j].Info, act[j].Info)621// }622// }623// }624// TODO: test these cases625// func TestDisplaysAreCreatedWithType(t *testing.T) {626// test.Assert(t, false, "untested")627// }628// func Test_writeDeckInfo(t *testing.T) {629// test.Assert(t, false, "untested")630// }631// func Test_makeCardsSetsDisplayTmpl(t *testing.T) {632// test.Assert(t, false, "untested")633// }634// func Test_makeCardsSetsInfoSet(t *testing.T) {635// test.Assert(t, false, "untested")636// }637// func TestLoadCards_CardsInfoGetsCreatedIfItDoesntExist(t *testing.T) {638// test.Assert(t, false, "untested")639// }640// TODO: separate out tests into their correct packages.641// TODO: test core package against mock interfaces, add tests for concrete types.642// TODO: test that type renders output correctly.643func TestCardRender(t *testing.T) {644 scopeTmplMap := core.ScopeTmplMap{645 "html": core.TmplMap{646 "thisdoesx": template.Must(template.New("base").Parse(`647 default this does x648 `)),649 "xdoesthat": template.Must(template.New("base").Parse(`650 default x does that651 `)),652 },653 "ppc": core.TmplMap{654 "thisdoesx": template.Must(template.New("base").Parse(`655 local this does x656 `)),657 },658 }659 testdata := []struct {660 c *core.Card661 exp string662 }{663 {664 c: &core.Card{Info: core.Info{Set: "ppc", Tmpl: "thisdoesx"}},665 exp: "local this does x",666 },667 {668 c: &core.Card{Info: core.Info{Set: "ppc", Tmpl: "xdoesthat"}},669 exp: "default x does that",670 },671 }672 for i, tt := range testdata {673 s, err := core.Render(scopeTmplMap, tt.c)674 test.Assert(t, err == nil, "test %v, render: %v", i, err)675 act := strings.TrimSpace(s)676 test.ExpectEQ(t, tt.exp, act, fmt.Sprintf("test %v", i))677 }678}...

Full Screen

Full Screen

Info

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 ppc := powerpc.New()4 fmt.Println(ppc.Info())5}6import (7func main() {8 ppc := powerpc.New()9 fmt.Println(ppc.Info())10}11import (12func main() {13 ppc := powerpc.New()14 fmt.Println(ppc.Info())15}16import (17func main() {18 ppc := powerpc.New()19 fmt.Println(ppc.Info())20}21import (22func main() {23 ppc := powerpc.New()24 fmt.Println(ppc.Info())25}26import (27func main() {28 ppc := powerpc.New()29 fmt.Println(ppc.Info())30}31import (32func main() {33 ppc := powerpc.New()34 fmt.Println(ppc.Info())35}36import (37func main() {38 ppc := powerpc.New()39 fmt.Println(ppc.Info())40}41import (42func main() {43 ppc := powerpc.New()44 fmt.Println(ppc.Info())45}

Full Screen

Full Screen

Info

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 p := powerpc{}4 p.Info()5}6import (7func main() {8 p := mylib.Powerpc{}9 p.Info()10}11import (12func main() {13 p := mylib.Powerpc{}14 p.info()15}16./4.go:11: p.info undefined (type mylib.Powerpc has no field or method info)17./4.go:11: p.info undefined (type mylib.Powerpc has no field or method info)18./4.go:11: p.info undefined (type mylib.Powerpc has no field or method info)19import (

Full Screen

Full Screen

Info

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 ppc := powerpc.Powerpc{}4 ppc.Info()5}6import (7func main() {8 amd := amd64.Amd64{}9 amd.Info()10}11import (12func main() {13 intel := intel64.Intel64{}14 intel.Info()15}16import (17func main() {18 arm := arm64.Arm64{}19 arm.Info()20}21import (22func main() {23 mips := mips64.Mips64{}

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 Syzkaller 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