Beispiel #1
0
func TestConformanceValidation(t *testing.T) {
	tests := getMatchingTests(listTestFiles(), "conformance_")

	h := NewMockMessagePipeHandle()
	proxyIn, proxyOut := h, h
	interfacePointer := test.ConformanceTestInterface_Pointer{pipeOwner(proxyIn)}
	impl := &conformanceValidator{false, test.NewConformanceTestInterfaceProxy(interfacePointer, waiter)}

	h = NewMockMessagePipeHandle()
	stubIn, stubOut := h, h
	interfaceRequest := test.ConformanceTestInterface_Request{pipeOwner(stubOut)}
	stub := test.NewConformanceTestInterfaceStub(interfaceRequest, impl, waiter)
	for _, test := range tests {
		bytes, handles := readTest(test)
		answer := readAnswer(test)
		impl.CheckArgs = strings.HasSuffix(test, "_good")
		stubIn.WriteMessage(bytes, handles, system.MOJO_WRITE_MESSAGE_FLAG_NONE)
		err := stub.ServeRequest()
		verifyValidationError(t, test, err, answer)

		if !impl.CheckArgs {
			continue
		}
		// Decode again to verify correctness of encoding.
		_, bytes, handles = proxyOut.ReadMessage(system.MOJO_READ_MESSAGE_FLAG_NONE)
		stubIn.WriteMessage(bytes, handles, system.MOJO_WRITE_MESSAGE_FLAG_NONE)
		if err := stub.ServeRequest(); err != nil {
			t.Fatalf("error processing encoded data for test %v: %v", test, err)
		}
		proxyOut.ReadMessage(system.MOJO_READ_MESSAGE_FLAG_NONE)
		// Do not compare encoded bytes, as some tests contain maps, that
		// can be encoded randomly.
	}
}
Beispiel #2
0
func TestConformanceResponse(t *testing.T) {
	h := NewMockMessagePipeHandle()
	checkProxy := func() error {
		interfacePointer := test.ConformanceTestInterface_Pointer{pipeOwner(h)}
		proxy := test.NewConformanceTestInterfaceProxy(interfacePointer, waiter)
		_, err := proxy.Method12(0)
		proxy.Close_Proxy()
		h.reset()
		return err
	}
	runTests(t, "resp_conformance_", h, checkProxy)
}