2021-06-18 13:51:18 +02:00
|
|
|
package torsf_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/experiment/torsf"
|
2021-06-22 00:12:03 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/mockable"
|
2022-01-03 13:53:23 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2021-06-18 13:51:18 +02:00
|
|
|
"golang.org/x/sys/execabs"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRunWithExistingTor(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skip test in short mode")
|
|
|
|
}
|
|
|
|
path, err := execabs.LookPath("tor")
|
|
|
|
if err != nil {
|
|
|
|
t.Skip("there is no tor executable installed")
|
|
|
|
}
|
|
|
|
t.Log("found tor in path:", path)
|
|
|
|
tempdir, err := ioutil.TempDir("", "")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
t.Log("using this tempdir", tempdir)
|
|
|
|
m := torsf.NewExperimentMeasurer(torsf.Config{})
|
|
|
|
ctx := context.Background()
|
|
|
|
measurement := &model.Measurement{}
|
|
|
|
callbacks := model.NewPrinterCallbacks(log.Log)
|
|
|
|
sess := &mockable.Session{
|
|
|
|
MockableLogger: log.Log,
|
|
|
|
MockableTempDir: tempdir,
|
|
|
|
}
|
|
|
|
if err = m.Run(ctx, sess, measurement, callbacks); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|