a50efdbcf1
The current implementation assumes the user has already installed tor on the current system. If tor is not present, the experiment fails. This is meant to be the first version of this experiment. We are going to add more functionality in subsequent revisions of this experiment, once we've collected more feedback. Reference issue: https://github.com/ooni/probe/issues/1565. Here's the spec PR: https://github.com/ooni/spec/pull/218. Here's the issue tracking future work: https://github.com/ooni/probe/issues/1686
41 lines
1001 B
Go
41 lines
1001 B
Go
package torsf_test
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/experiment/torsf"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/internal/mockable"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
|
"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)
|
|
}
|
|
}
|