(t *testing.T)
| 654 | } |
| 655 | |
| 656 | func TestMarshalRace(t *testing.T) { |
| 657 | ext := &pb.Ext{} |
| 658 | m := &pb.MyMessage{Count: proto.Int32(4)} |
| 659 | if err := proto.SetExtension(m, pb.E_Ext_More, ext); err != nil { |
| 660 | t.Fatalf("proto.SetExtension(m, desc, true): got error %q, want nil", err) |
| 661 | } |
| 662 | |
| 663 | b, err := proto.Marshal(m) |
| 664 | if err != nil { |
| 665 | t.Fatalf("Could not marshal message: %v", err) |
| 666 | } |
| 667 | if err := proto.Unmarshal(b, m); err != nil { |
| 668 | t.Fatalf("Could not unmarshal message: %v", err) |
| 669 | } |
| 670 | // after Unmarshal, the extension is in undecoded form. |
| 671 | // GetExtension will decode it lazily. Make sure this does |
| 672 | // not race against Marshal. |
| 673 | |
| 674 | errChan := make(chan error, 6) |
| 675 | for n := 3; n > 0; n-- { |
| 676 | go func() { |
| 677 | _, err := proto.Marshal(m) |
| 678 | errChan <- err |
| 679 | }() |
| 680 | go func() { |
| 681 | _, err := proto.GetExtension(m, pb.E_Ext_More) |
| 682 | errChan <- err |
| 683 | }() |
| 684 | } |
| 685 | for i := 0; i < 6; i++ { |
| 686 | err := <-errChan |
| 687 | if err != nil { |
| 688 | t.Fatal(err) |
| 689 | } |
| 690 | } |
| 691 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…