func resolveOper(oper *tpb.GetSetValidationOper, lib *spb.CommonMessages) (*tpb.GetSetValidationOper, error) {
	gn := oper.GetCommonGetrequest()
	sn := oper.GetCommonSetrequest()
	gr := oper.GetCommonGetresponse()
	switch {
	case gn == "" && sn == "" && gr == "":
		return oper, nil
	case (gn != "" || sn != "" || gr != "") && lib == nil:
		return nil, fmt.Errorf("cannot look up common requests (Get: %s, Set: %s), nil library", gn, sn)
	case gn != "" && lib.GetRequests == nil:
		return nil, fmt.Errorf("cannot look up common GetRequest %s, nil GetRequest library", gn)
	case sn != "" && lib.SetRequests == nil:
		return nil, fmt.Errorf("cannot look up common SetRequest %s, nil SetRequest library", sn)
	}
	rt := proto.Clone(oper).(*tpb.GetSetValidationOper)
	if gn != "" {
		req, ok := lib.GetRequests[gn]
		if !ok {
			return nil, fmt.Errorf("common GetRequest %s does not exist", gn)
		}
		rt.Getrequest = &tpb.GetSetValidationOper_Get{req}
	}
	if sn != "" {
		req, ok := lib.SetRequests[sn]
		if !ok {
			return nil, fmt.Errorf("common SetRequest %s does not exist", sn)
		}
		rt.Setrequest = &tpb.GetSetValidationOper_Set{req}
	}
	if gr != "" {
		res, ok := lib.GetResponses[gr]
		if !ok {
			return nil, fmt.Errorf("common GetResponse %s does not exist", gr)
		}
		rt.Getresponse = &tpb.GetSetValidationOper_GetResponse{res}
	}
	return rt, nil
}
resolveOper looks up the common messages that are specified in the supplied
oper in the lib provided. The fully resolved GetSetValidationOper is returned
to the caller.
package getsetv
import (
	"context"
	"fmt"
	log "github.com/golang/glog"
	"github.com/golang/protobuf/proto"
	"github.com/openconfig/gnmitest/common"
	"github.com/openconfig/ygot/testutil"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	gpb "github.com/openconfig/gnmi/proto/gnmi"
	rpb "github.com/openconfig/gnmitest/proto/report"
	spb "github.com/openconfig/gnmitest/proto/suite"
	tpb "github.com/openconfig/gnmitest/proto/tests"
)
type Specification struct {
	Connection     *tpb.Connection      
	Instance       *spb.Instance        
	Result         *rpb.Instance        
	CommonRequests *spb.CommonMessages  
}
func GetSetValidate(ctx context.Context, testInst *tpb.GetSetValidationTest, spec *Specification) error {
	log.Infof("connecting to target %s", spec.Connection.Address)
	creds, err := common.ResolveCredentials(ctx, spec.Connection)
	if err != nil {
		return fmt.Errorf("cannot resolve credentials, %v", err)
	}
	ctx = common.ContextWithAuth(ctx, creds)
	conn, cleanup, err := common.Connect(ctx, spec.Connection)
	if err != nil {
		return fmt.Errorf("cannot connect to target: %v", err)
	}
	defer cleanup()
	o, err := resolveOper(testInst.GetInitialiseOper(), spec.CommonRequests)
	if err != nil {
		return fmt.Errorf("cannot resolve initialise oper, %v", err)
	}
	t, err := resolveOper(testInst.GetTestOper(), spec.CommonRequests)
	if err != nil {
		return fmt.Errorf("cannot resolve test oper, %v", err)
	}
	ti := proto.Clone(testInst).(*tpb.GetSetValidationTest)
	ti.InitialiseOper = o
	ti.TestOper = t
	iRes, iPass, err := doOper(ctx, conn, ti.InitialiseOper)
	if err != nil {
		return fmt.Errorf("cannot run initialise oper, got error: %v", err)
	}
	tRes, tPass, err := doOper(ctx, conn, ti.TestOper)
	if err != nil {
		return fmt.Errorf("cannot run test oper, got err: %v", err)
	}
	passRes := func(a, b bool) rpb.Status {
		if a && b {
			return rpb.Status_SUCCESS
		}
		return rpb.Status_FAIL
	}
	spec.Result.Test = &rpb.TestResult{
		Test:   spec.Instance.GetTest(),
		Result: passRes(iPass, tPass),
		Type: &rpb.TestResult_Getset{
			&rpb.GetSetTestResult{
				Result:         passRes(iPass, tPass),
				InitialiseOper: iRes,
				TestOper:       tRes,
			},
		},
	}
	return nil
}