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