<commit_before>package upnp

import (
	"testing"
)

// TestConcurrentUPNP tests that several threads calling Discover() concurrently
// succeed.
func TestConcurrentUPNP(t *testing.T) {
	// verify that a router exists
	_, err := Discover()
	if err != nil {
		t.Fatal(err)
	}

	// now try to concurrently Discover() using 10 threads
	for i := 0; i < 10; i++ {
		go func() {
			_, err := Discover()
			if err != nil {
				t.Fatal(err)
			}
		}()
	}
}

func TestIGD(t *testing.T) {
	// connect to router
	d, err := Discover()
	if err != nil {
		t.Fatal(err)
	}

	// discover external IP
	ip, err := d.ExternalIP()
	if err != nil {
		t.Fatal(err)
	}
	t.Log("Your external IP is:", ip)

	// forward a port
	err = d.Forward(9001, "upnp test")
	if err != nil {
		t.Fatal(err)
	}<commit_msg>wait for all discover threads to complete<commit_after>package upnp

import (
	"sync"
	"testing"
)

// TestConcurrentUPNP tests that several threads calling Discover() concurrently
// succeed.
func TestConcurrentUPNP(t *testing.T) {
	if testing.Short() {
		t.SkipNow()
	}
	// verify that a router exists
	_, err := Discover()
	if err != nil {
		t.Fatal(err)
	}

	// now try to concurrently Discover() using 20 threads
	var wg sync.WaitGroup
	for i := 0; i < 20; i++ {
		go func() {
			wg.Add(1)
			defer wg.Done()
			_, err := Discover()
			if err != nil {
				t.Fatal(err)
			}
		}()
	}
	wg.Wait()
}

func TestIGD(t *testing.T) {
	// connect to router
	d, err := Discover()
	if err != nil {
		t.Fatal(err)
	}

	// discover external IP
	ip, err := d.ExternalIP()
	if err != nil {
		t.Fatal(err)
	}
	t.Log("Your external IP is:", ip)

	// forward a port
	err = d.Forward(9001, "upnp test")
	if err != nil {
		t.Fatal(err)
	}
{'fraction_non_alphanumeric': 0.15483870967741936, 'fraction_numerical': 0.011143695014662757, 'mean_word_length': 2.8165548098434003, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5848297', 'n_tokens_mistral': 726, 'n_tokens_neox': 639, 'n_words': 193}