}
func runClientTestForVersion(t *testing.T, template *clientTest, version, option string) {
- t.Run(version, func(t *testing.T) {
- // Make a deep copy of the template before going parallel.
- test := *template
- if template.config != nil {
- test.config = template.config.Clone()
- }
-
- if !*update {
- t.Parallel()
- }
+ // Make a deep copy of the template before going parallel.
+ test := *template
+ if template.config != nil {
+ test.config = template.config.Clone()
+ }
+ test.name = version + "-" + test.name
+ test.args = append([]string{option}, test.args...)
- test.name = version + "-" + test.name
- test.args = append([]string{option}, test.args...)
- test.run(t, *update)
- })
+ runTestAndUpdateIfNeeded(t, version, test.run, false)
}
func runClientTestTLS10(t *testing.T, template *clientTest) {
}
func runServerTestForVersion(t *testing.T, template *serverTest, version, option string) {
- t.Run(version, func(t *testing.T) {
- // Make a deep copy of the template before going parallel.
- test := *template
- if template.config != nil {
- test.config = template.config.Clone()
- }
-
- if !*update && !template.wait {
- t.Parallel()
- }
+ // Make a deep copy of the template before going parallel.
+ test := *template
+ if template.config != nil {
+ test.config = template.config.Clone()
+ }
+ test.name = version + "-" + test.name
+ if len(test.command) == 0 {
+ test.command = defaultClientCommand
+ }
+ test.command = append([]string(nil), test.command...)
+ test.command = append(test.command, option)
- test.name = version + "-" + test.name
- if len(test.command) == 0 {
- test.command = defaultClientCommand
- }
- test.command = append([]string(nil), test.command...)
- test.command = append(test.command, option)
- test.run(t, *update)
- })
+ runTestAndUpdateIfNeeded(t, version, test.run, test.wait)
}
func runServerTestTLS10(t *testing.T, template *serverTest) {
// implementation.
//
// Tests can be updated by running them with the -update flag. This will cause
-// the test files to be regenerated. Generally one should combine the -update
-// flag with -test.run to updated a specific test. Since the reference
-// implementation will always generate fresh random numbers, large parts of
-// the reference connection will always change.
+// the test files for failing tests to be regenerated. Since the reference
+// implementation will always generate fresh random numbers, large parts of the
+// reference connection will always change.
var (
- update = flag.Bool("update", false, "update golden files on disk")
+ update = flag.Bool("update", false, "update golden files on failure")
fast = flag.Bool("fast", false, "impose a quick, possibly flaky timeout on recorded tests")
keyFile = flag.String("keylog", "", "destination file for KeyLogWriter")
)
+func runTestAndUpdateIfNeeded(t *testing.T, name string, run func(t *testing.T, update bool), wait bool) {
+ success := t.Run(name, func(t *testing.T) {
+ if !*update && !wait {
+ t.Parallel()
+ }
+ run(t, false)
+ })
+
+ if !success && *update {
+ t.Run(name+"#update", func(t *testing.T) {
+ run(t, true)
+ })
+ }
+}
+
// checkOpenSSLVersion ensures that the version of OpenSSL looks reasonable
// before updating the test data.
func checkOpenSSLVersion() error {