Debian Codegraph @

util/intelp2m/parser/template/template_test.go

raw symbols SCIP
1 package template_test
2
3 import (
4 "fmt"
5 "testing"
6
7 "review.coreboot.org/coreboot.git/util/intelp2m/parser/template"
8 )
9
10 func TestTemp(t *testing.T) {
11 t.Run("TEMPLATE/INTELTOOL-LINE", func(t *testing.T) {
12 const (
13 IntSelMask uint32 = 0xffffff00
14 ref_fn string = "SLP_S0#"
15 ref_id string = "GPP_B12"
16 ref_dw0 uint32 = 0x44000600
17 ref_dw1 uint32 = 0x0000003c
18 )
19 var (
20 fn, id string
21 dw0, dw1 uint32
22 )
23 line := fmt.Sprintf("0x0520: 0x%08x%08x %s %s", ref_dw1, ref_dw0, ref_id, ref_fn)
24 fn, id, dw0, dw1, err := template.Apply(line)
25 if err != nil {
26 t.Errorf("template application failure: %d", err)
27 }
28 if fn != ref_fn {
29 t.Errorf("function from '%s':\nExpects: '%s'\nActually: '%s'\n\n",
30 line, ref_fn, fn)
31 } else if id != ref_id {
32 t.Errorf("id from '%s':\nExpects: '%s'\nActually: '%s'\n\n",
33 line, ref_id, id)
34 } else if dw0 != ref_dw0 {
35 t.Errorf("dw0 from '%s':\nExpects: '0x%08x'\nActually: '0x%08x'\n\n",
36 line, ref_dw0, dw0)
37 } else if dw1 != (ref_dw1 & IntSelMask) {
38 t.Errorf("dw1 from '%s':\nExpects: '0x%08x'\nActually: '0x%08x'\n\n",
39 line, (ref_dw1 & IntSelMask), dw1)
40 }
41 })
42 }