Best Syzkaller code snippet using x86.out
deps_test.go
Source:deps_test.go
...14package makedeps15import (16 "bytes"17 "io"18 "io/ioutil"19 "os"20 "testing"21)22func TestParse(t *testing.T) {23 testCases := []struct {24 name string25 input string26 output Deps27 err error28 }{29 // These come from the ninja test suite30 {31 name: "Basic",32 input: "build/ninja.o: ninja.cc ninja.h eval_env.h manifest_parser.h",33 output: Deps{34 Output: "build/ninja.o",35 Inputs: []string{36 "ninja.cc",37 "ninja.h",38 "eval_env.h",39 "manifest_parser.h",40 },41 },42 },43 {44 name: "EarlyNewlineAndWhitespace",45 input: ` \46 out: in`,47 output: Deps{48 Output: "out",49 Inputs: []string{"in"},50 },51 },52 {53 name: "Continuation",54 input: `foo.o: \55 bar.h baz.h56`,57 output: Deps{58 Output: "foo.o",59 Inputs: []string{"bar.h", "baz.h"},60 },61 },62 {63 name: "CarriageReturnContinuation",64 input: "foo.o: \\\r\n bar.h baz.h\r\n",65 output: Deps{66 Output: "foo.o",67 Inputs: []string{"bar.h", "baz.h"},68 },69 },70 {71 name: "BackSlashes",72 input: `Project\Dir\Build\Release8\Foo\Foo.res : \73 Dir\Library\Foo.rc \74 Dir\Library\Version\Bar.h \75 Dir\Library\Foo.ico \76 Project\Thing\Bar.tlb \77`,78 output: Deps{79 Output: `Project\Dir\Build\Release8\Foo\Foo.res`,80 Inputs: []string{81 `Dir\Library\Foo.rc`,82 `Dir\Library\Version\Bar.h`,83 `Dir\Library\Foo.ico`,84 `Project\Thing\Bar.tlb`,85 },86 },87 },88 {89 name: "Spaces",90 input: `a\ bc\ def: a\ b c d`,91 output: Deps{92 Output: `a bc def`,93 Inputs: []string{"a b", "c", "d"},94 },95 },96 {97 name: "Escapes",98 input: `\!\@\#$$\%\^\&\\:`,99 output: Deps{100 Output: `\!\@#$\%\^\&\`,101 },102 },103 {104 name: "SpecialChars",105 // Ninja includes a number of '=', but our parser can't handle that,106 // since it sees the equals and switches over to assuming it's an107 // assignment.108 //109 // We don't have any files in our tree that contain an '=' character,110 // and Kati can't handle parsing this either, so for now I'm just111 // going to remove all the '=' characters below.112 //113 // It looks like make will only do this for the first114 // dependency, but not later dependencies.115 input: `C\:/Program\ Files\ (x86)/Microsoft\ crtdefs.h: \116 en@quot.header~ t+t-x!1 \117 openldap/slapd.d/cnconfig/cnschema/cn{0}core.ldif \118 Fu` + "\303\244ball",119 output: Deps{120 Output: "C:/Program Files (x86)/Microsoft crtdefs.h",121 Inputs: []string{122 "en@quot.header~",123 "t+t-x!1",124 "openldap/slapd.d/cnconfig/cnschema/cn{0}core.ldif",125 "Fu\303\244ball",126 },127 },128 },129 // Ninja's UnifyMultipleOutputs and RejectMultipleDifferentOutputs tests have been omitted,130 // since we don't want the same behavior.131 // Our own tests132 {133 name: "Multiple outputs",134 input: `a b: c135a: d136b: e`,137 output: Deps{138 Output: "b",139 Inputs: []string{140 "c",141 "d",142 "e",143 },144 },145 },146 }147 for _, tc := range testCases {148 t.Run(tc.name, func(t *testing.T) {149 out, err := Parse("test.d", bytes.NewBufferString(tc.input))150 if err != tc.err {151 t.Fatalf("Unexpected error: %v (expected %v)", err, tc.err)152 }153 if out.Output != tc.output.Output {154 t.Errorf("output file doesn't match:\n"+155 " str: %#v\n"+156 "want: %#v\n"+157 " got: %#v", tc.input, tc.output.Output, out.Output)158 }159 matches := true160 if len(out.Inputs) != len(tc.output.Inputs) {161 matches = false162 } else {163 for i := range out.Inputs {164 if out.Inputs[i] != tc.output.Inputs[i] {165 matches = false166 }167 }168 }169 if !matches {170 t.Errorf("input files don't match:\n"+171 " str: %#v\n"+172 "want: %#v\n"+173 " got: %#v", tc.input, tc.output.Inputs, out.Inputs)174 }175 })176 }177}178func BenchmarkParsing(b *testing.B) {179 // Write it out to a file to most closely match ninja's perftest180 tmpfile, err := ioutil.TempFile("", "depfile")181 if err != nil {182 b.Fatal("Failed to create temp file:", err)183 }184 defer os.Remove(tmpfile.Name())185 _, err = io.WriteString(tmpfile, `out/soong/.intermediates/external/ninja/ninja/linux_glibc_x86_64/obj/external/ninja/src/ninja.o: \186 external/ninja/src/ninja.cc external/libcxx/include/errno.h \187 external/libcxx/include/__config \188 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/features.h \189 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/predefs.h \190 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/sys/cdefs.h \191 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/wordsize.h \192 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/gnu/stubs.h \193 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \194 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/errno.h \195 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/errno.h \196 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/linux/errno.h \197 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/asm/errno.h \198 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/asm-generic/errno.h \199 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/asm-generic/errno-base.h \200 external/libcxx/include/limits.h \201 prebuilts/clang/host/linux-x86/clang-4639204/lib64/clang/6.0.1/include/limits.h \202 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/limits.h \203 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/posix1_lim.h \204 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/local_lim.h \205 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/linux/limits.h \206 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/posix2_lim.h \207 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/xopen_lim.h \208 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \209 external/libcxx/include/stdio.h \210 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/stdio.h \211 external/libcxx/include/stddef.h \212 prebuilts/clang/host/linux-x86/clang-4639204/lib64/clang/6.0.1/include/stddef.h \213 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/types.h \214 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/typesizes.h \215 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/libio.h \216 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/_G_config.h \217 external/libcxx/include/wchar.h \218 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/wchar.h \219 prebuilts/clang/host/linux-x86/clang-4639204/lib64/clang/6.0.1/include/stdarg.h \220 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \221 external/libcxx/include/stdlib.h \222 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/stdlib.h \223 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/waitflags.h \224 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/waitstatus.h \225 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/endian.h \226 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/endian.h \227 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/byteswap.h \228 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/xlocale.h \229 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/sys/types.h \230 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/time.h \231 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/sys/select.h \232 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/select.h \233 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/sigset.h \234 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/time.h \235 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/select2.h \236 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/sys/sysmacros.h \237 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \238 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/alloca.h \239 external/libcxx/include/string.h \240 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/string.h \241 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/getopt.h \242 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/unistd.h \243 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/posix_opt.h \244 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/environments.h \245 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/confname.h \246 external/ninja/src/browse.h external/ninja/src/build.h \247 external/libcxx/include/cstdio external/libcxx/include/map \248 external/libcxx/include/__tree external/libcxx/include/iterator \249 external/libcxx/include/iosfwd \250 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/wchar.h \251 external/libcxx/include/__functional_base \252 external/libcxx/include/type_traits external/libcxx/include/cstddef \253 prebuilts/clang/host/linux-x86/clang-4639204/lib64/clang/6.0.1/include/__stddef_max_align_t.h \254 external/libcxx/include/__nullptr external/libcxx/include/typeinfo \255 external/libcxx/include/exception external/libcxx/include/cstdlib \256 external/libcxx/include/cstdint external/libcxx/include/stdint.h \257 prebuilts/clang/host/linux-x86/clang-4639204/lib64/clang/6.0.1/include/stdint.h \258 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/stdint.h \259 external/libcxx/include/new external/libcxx/include/utility \260 external/libcxx/include/__tuple \261 external/libcxx/include/initializer_list \262 external/libcxx/include/cstring external/libcxx/include/__debug \263 external/libcxx/include/memory external/libcxx/include/limits \264 external/libcxx/include/__undef_macros external/libcxx/include/tuple \265 external/libcxx/include/stdexcept external/libcxx/include/cassert \266 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/assert.h \267 external/libcxx/include/atomic external/libcxx/include/algorithm \268 external/libcxx/include/functional external/libcxx/include/queue \269 external/libcxx/include/deque external/libcxx/include/__split_buffer \270 external/libcxx/include/vector external/libcxx/include/__bit_reference \271 external/libcxx/include/climits external/libcxx/include/set \272 external/libcxx/include/string external/libcxx/include/string_view \273 external/libcxx/include/__string external/libcxx/include/cwchar \274 external/libcxx/include/cwctype external/libcxx/include/cctype \275 external/libcxx/include/ctype.h \276 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/ctype.h \277 external/libcxx/include/wctype.h \278 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/wctype.h \279 external/ninja/src/graph.h external/ninja/src/eval_env.h \280 external/ninja/src/string_piece.h external/ninja/src/timestamp.h \281 external/ninja/src/util.h external/ninja/src/exit_status.h \282 external/ninja/src/line_printer.h external/ninja/src/metrics.h \283 external/ninja/src/build_log.h external/ninja/src/hash_map.h \284 external/libcxx/include/unordered_map \285 external/libcxx/include/__hash_table external/libcxx/include/cmath \286 external/libcxx/include/math.h \287 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/math.h \288 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/huge_val.h \289 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/huge_valf.h \290 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/huge_vall.h \291 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/inf.h \292 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/nan.h \293 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/mathdef.h \294 prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot/usr/include/x86_64-linux-gnu/bits/mathcalls.h \295 external/ninja/src/deps_log.h external/ninja/src/clean.h \296 external/ninja/src/debug_flags.h external/ninja/src/disk_interface.h \297 external/ninja/src/graphviz.h external/ninja/src/manifest_parser.h \298 external/ninja/src/lexer.h external/ninja/src/state.h \299 external/ninja/src/version.h`)300 tmpfile.Close()301 if err != nil {302 b.Fatal("Failed to write dep file:", err)303 }304 b.ResetTimer()305 for n := 0; n < b.N; n++ {306 depfile, err := ioutil.ReadFile(tmpfile.Name())307 if err != nil {308 b.Fatal("Failed to read dep file:", err)309 }310 _, err = Parse(tmpfile.Name(), bytes.NewBuffer(depfile))311 if err != nil {312 b.Fatal("Failed to parse:", err)313 }314 }315}316func TestDepPrint(t *testing.T) {317 testCases := []struct {318 name string319 input Deps320 output string321 }{322 {323 name: "Empty",324 input: Deps{325 Output: "a",326 },327 output: "a:",328 },329 {330 name: "Basic",331 input: Deps{332 Output: "a",333 Inputs: []string{"b", "c"},334 },335 output: "a: b c",336 },337 {338 name: "Escapes",339 input: Deps{340 Output: `\!\@#$\%\^\&\`,341 },342 output: `\\!\\@\#$$\\%\\^\\&\\:`,343 },344 {345 name: "Spaces",346 input: Deps{347 Output: "a b",348 Inputs: []string{"c d", "e f "},349 },350 output: `a\ b: c\ d e\ f\ `,351 },352 {353 name: "SpecialChars",354 input: Deps{355 Output: "C:/Program Files (x86)/Microsoft crtdefs.h",356 Inputs: []string{357 "en@quot.header~",358 "t+t-x!1",359 "openldap/slapd.d/cnconfig/cnschema/cn{0}core.ldif",360 "Fu\303\244ball",361 },362 },363 output: `C\:/Program\ Files\ (x86)/Microsoft\ crtdefs.h: en@quot.header~ t+t-x!1 openldap/slapd.d/cnconfig/cnschema/cn{0}core.ldif Fu` + "\303\244ball",364 },365 }366 for _, tc := range testCases {367 t.Run(tc.name, func(t *testing.T) {368 out := tc.input.Print()369 outStr := string(out)370 want := tc.output + "\n"371 if outStr != want {372 t.Errorf("output doesn't match:\nwant:%q\n got:%q", want, outStr)373 }374 })375 }376}...
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!!