github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/tools/syz-kconf/kconf_test.go (about) 1 // Copyright 2021 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package main 5 6 import ( 7 "fmt" 8 "testing" 9 ) 10 11 func TestReleaseTag(t *testing.T) { 12 type Test struct { 13 in string 14 out string 15 err bool 16 } 17 tests := []Test{ 18 { 19 in: ` 20 VERSION = 4 21 PATCHLEVEL = 19 22 SUBLEVEL = 144 23 EXTRAVERSION = 24 `, 25 out: "v4.19", 26 }, 27 { 28 in: ` 29 VERSION = 5 30 PATCHLEVEL = 4 31 SUBLEVEL = 0 32 EXTRAVERSION = 33 `, 34 out: "v5.4", 35 }, 36 { 37 in: ` 38 VERSION = 5 39 PATCHLEVEL = 11 40 SUBLEVEL = 0 41 EXTRAVERSION = -rc3 42 `, 43 out: "v5.11", 44 }, 45 { 46 in: ` 47 PATCHLEVEL = 11 48 SUBLEVEL = 0 49 EXTRAVERSION = -rc3 50 `, 51 err: true, 52 }, 53 } 54 for i, test := range tests { 55 t.Run(fmt.Sprint(i), func(t *testing.T) { 56 got, err := releaseTagImpl([]byte(test.in)) 57 if test.err != (err != nil) { 58 t.Fatalf("expected err=%v, got %q", test.err, err) 59 } 60 if test.out != got { 61 t.Fatalf("expected release %q, got %q", test.out, got) 62 } 63 }) 64 } 65 }