Skip to content

Commit

Permalink
fuzz-marshal-float-64ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksiienkoMykyta committed Jun 10, 2024
1 parent 34fdeeb commit 6c840db
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 35 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ jobs:
- run: go vet
- name: Run unit tests
run: go test -v -tags unit -race

Fuzzing:
name: Fuzz tests
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.19', '1.20' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- run: go vet
- name: Run unit tests
run: go test -race -v -fuzz Fuzz -fuzztime 30s -parallel=1 -tags fuzz
integration-cassandra:
timeout-minutes: 15
needs:
Expand Down Expand Up @@ -198,4 +213,4 @@ jobs:
- name: Integration tests
run: |
export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }}
go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }}
34 changes: 0 additions & 34 deletions fuzz.go

This file was deleted.

31 changes: 31 additions & 0 deletions fuzz_cassandra_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//go:build fuzz
// +build fuzz

package gocql

import (
"testing"
)

// FuzzMarshalFloat64Ptr aimed to repeatedly test float64 marshaling with generated inputs based on seed corpus.
func FuzzMarshalFloat64Ptr(f *testing.F) {
f.Add(float64(7500), float64(7500.00))

f.Fuzz(func(t *testing.T, num, numWithPoints float64) {
session := createSession(t, &ClusterConfig{ProtoVersion: protoVersion3})

Check failure on line 15 in fuzz_cassandra_test.go

View workflow job for this annotation

GitHub Actions / Fuzz tests (1.19)

cannot use &ClusterConfig{…} (value of type *ClusterConfig) as type func(config *ClusterConfig) in argument to createSession

Check failure on line 15 in fuzz_cassandra_test.go

View workflow job for this annotation

GitHub Actions / Fuzz tests (1.20)

cannot use &ClusterConfig{…} (value of type *ClusterConfig) as func(config *ClusterConfig) value in argument to createSession

defer session.Close()

if err := createTable(session, "CREATE TABLE IF NOT EXISTS gocql_test.float_test (id double, test double, primary key (id))"); err != nil {
t.Fatal("create table:", err)
}

if err := session.Query(`TRUNCATE TABLE gocql_test.float_test`).Exec(); err != nil {
t.Fatal("truncate table:", err)
}

if err := session.Query(`INSERT INTO float_test (id,test) VALUES (?,?)`, numWithPoints, &num).Exec(); err != nil {
t.Fatal("insert float64:", err)
}
})
}

0 comments on commit 6c840db

Please sign in to comment.