<commit_before>package gosecco

import (
	"testing"

	"golang.org/x/sys/unix"

	. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }

type SeccompSuite struct{}

var _ = Suite(&SeccompSuite{})

func (s *SeccompSuite) Test_loadingTooBigBpf(c *C) {
	inp := make([]unix.SockFilter, 0xFFFF+1)
	res := Load(inp)
	c.Assert(res, ErrorMatches, "filter program too big: 65536 bpf instructions \\(limit = 65535\\)")
}<commit_msg>test that parse errors are returned from API interface<commit_after>package gosecco

import (
	"os"
	"path"
	"strings"
	"testing"

	"golang.org/x/sys/unix"

	. "gopkg.in/check.v1"
)

func Test(t *testing.T) { TestingT(t) }

type SeccompSuite struct{}

var _ = Suite(&SeccompSuite{})

func (s *SeccompSuite) Test_loadingTooBigBpf(c *C) {
	inp := make([]unix.SockFilter, 0xFFFF+1)
	res := Load(inp)
	c.Assert(res, ErrorMatches, "filter program too big: 65536 bpf instructions \\(limit = 65535\\)")
}

func getActualTestFolder() string {
	wd, _ := os.Getwd()
	if strings.HasSuffix(wd, "/parser") {
		return wd
	}
	return path.Join(wd, "parser")
}

func (s *SeccompSuite) Test_parseInvalidFileReturnsErrors(c *C) {
	set := SeccompSettings{}
	f := getActualTestFolder() + "/failing_test_policy"
	_, ee := Prepare(f, set)
	c.Assert(ee, ErrorMatches, ".*parser/failing_test_policy:1: unexpected end of line")

}
{'fraction_non_alphanumeric': 0.15805243445692885, 'fraction_numerical': 0.020224719101123594, 'mean_word_length': 4.758620689655173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6134246', 'n_tokens_mistral': 568, 'n_tokens_neox': 533, 'n_words': 116}