av/cmd/rv/probe_test.go

63 lines
1.7 KiB
Go
Raw Normal View History

/*
DESCRIPTION
Testing function for turbidity probe.
AUTHORS
Russell Stanley <russell@ausocean.org>
LICENSE
Copyright (C) 2021-2022 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package main
import (
"io"
2022-01-10 06:47:52 +03:00
"io/ioutil"
"testing"
"time"
"bitbucket.org/ausocean/utils/logger"
"gopkg.in/natefinch/lumberjack.v2"
2022-01-10 06:47:52 +03:00
)
// TestProbe reads a given video file and writes the sharpness and contrast scores to a turbidity probe.
2022-01-11 07:05:53 +03:00
func TestProbe(t *testing.T) {
// Create lumberjack logger.
fileLog := &lumberjack.Logger{
Filename: logPath,
MaxSize: logMaxSize,
MaxBackups: logMaxBackup,
MaxAge: logMaxAge,
}
log := logger.New(logVerbosity, io.MultiWriter(fileLog), logSuppress)
ts, err := NewTurbidityProbe(*log, time.Microsecond)
if err != nil {
t.Fatalf("failed to create turbidity probe")
}
2022-01-11 07:05:53 +03:00
video, err := ioutil.ReadFile("logo.h264")
2022-01-10 06:47:52 +03:00
if err != nil {
2022-01-11 07:05:53 +03:00
t.Fatalf("failed to read file: %v", err)
2022-01-10 06:47:52 +03:00
}
2022-01-11 07:05:53 +03:00
_, err = ts.Write(video)
2022-01-10 06:47:52 +03:00
if err != nil {
2022-01-11 07:05:53 +03:00
t.Fatalf("failed to write sharpness and contrast: %v", err)
2022-01-10 06:47:52 +03:00
}
2022-01-11 07:05:53 +03:00
t.Logf("contrast: %v, sharpness: %v\n", ts.contrast, ts.sharpness)
}