-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
main_test.go
38 lines (31 loc) · 850 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright © 2015-2020 Hilko Bengen <[email protected]>
// All rights reserved.
//
// Use of this source code is governed by the license that can be
// found in the LICENSE file.
package yara
import (
"io/ioutil"
"log"
"os"
"testing"
)
var compiledTestRulesPath string
func TestMain(m *testing.M) {
r, err := Compile(`rule test : tag1 { meta: author = "Hilko Bengen" strings: $a = "abc" fullword condition: $a }`, nil)
if err != nil {
log.Fatalf("Compile: %v", err)
}
f, err := ioutil.TempFile("", "testrules.yac")
if err != nil {
log.Fatalf("ioutil.TempFile: %v", err)
}
compiledTestRulesPath = f.Name()
if err := r.Save(compiledTestRulesPath); err != nil {
os.Remove(compiledTestRulesPath)
log.Fatalf("Save(%q): %v", compiledTestRulesPath, err)
}
rc := m.Run()
os.Remove(compiledTestRulesPath)
os.Exit(rc)
}