Signed-off-by: shuai-z <zs.broccoli@gmail.com>
| ... | ... |
@@ -214,3 +214,19 @@ func TestPortAllocation(t *testing.T) {
|
| 214 | 214 |
t.Fatal("Requesting a dynamic port should never allocate a used port")
|
| 215 | 215 |
} |
| 216 | 216 |
} |
| 217 |
+ |
|
| 218 |
+func TestNoDuplicateBPR(t *testing.T) {
|
|
| 219 |
+ defer reset() |
|
| 220 |
+ |
|
| 221 |
+ if port, err := RequestPort(defaultIP, "tcp", BeginPortRange); err != nil {
|
|
| 222 |
+ t.Fatal(err) |
|
| 223 |
+ } else if port != BeginPortRange {
|
|
| 224 |
+ t.Fatalf("Expected port %d got %d", BeginPortRange, port)
|
|
| 225 |
+ } |
|
| 226 |
+ |
|
| 227 |
+ if port, err := RequestPort(defaultIP, "tcp", 0); err != nil {
|
|
| 228 |
+ t.Fatal(err) |
|
| 229 |
+ } else if port == BeginPortRange {
|
|
| 230 |
+ t.Fatalf("Acquire(0) allocated the same port twice: %d", port)
|
|
| 231 |
+ } |
|
| 232 |
+} |