1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris
15 const ubuntuTrustyAvahi
= `# /etc/nsswitch.conf
17 # Example configuration of GNU Name Service Switch functionality.
18 # If you have the libc-doc-reference' and nfo' packages installed, try:
19 # nfo libc "Name Service Switch"' for information about this file.
25 hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
36 func TestParseNSSConf(t
*testing
.T
) {
46 sources
: map[string][]nssSource
{
47 "foo": {{source
: "a"}, {source
: "b"}},
55 sources
: map[string][]nssSource
{
56 "foo": {{source
: "a"}, {source
: "b"}},
64 sources
: map[string][]nssSource
{
65 "foo": {{source
: "a"}, {source
: "b"}},
73 sources
: map[string][]nssSource
{
74 "foo": {{source
: "a"}, {source
: "b"}},
82 sources
: map[string][]nssSource
{
83 "foo": {{source
: "a"}, {source
: "b"}},
89 in
: " foo:a b [!a=b X=Y ] c#d \n",
91 sources
: map[string][]nssSource
{
96 criteria
: []nssCriterion
{
114 // Ubuntu Trusty w/ avahi-daemon, libavahi-* etc installed.
116 name
: "ubuntu_trusty_avahi",
117 in
: ubuntuTrustyAvahi
,
119 sources
: map[string][]nssSource
{
120 "passwd": {{source
: "compat"}},
121 "group": {{source
: "compat"}},
122 "shadow": {{source
: "compat"}},
126 source
: "mdns4_minimal",
127 criteria
: []nssCriterion
{
138 "networks": {{source
: "files"}},
163 for _
, tt
:= range tests
{
164 gotConf
:= parseNSSConf(strings
.NewReader(tt
.in
))
165 if !reflect
.DeepEqual(gotConf
, tt
.want
) {
166 t
.Errorf("%s: mismatch\n got %#v\nwant %#v", tt
.name
, gotConf
, tt
.want
)