| 
									
										
										
										
											2014-04-14 14:02:44 +02:00
										 |  |  | # Test whether `avahi-daemon' and `libnss-mdns' work as expected. | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  | import ./make-test.nix ({ pkgs, ... } : { | 
					
						
							| 
									
										
										
										
											2014-06-28 16:04:49 +02:00
										 |  |  |   name = "avahi"; | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  |   meta = with pkgs.stdenv.lib.maintainers; { | 
					
						
							| 
									
										
										
										
											2015-08-04 17:30:14 +02:00
										 |  |  |     maintainers = [ eelco chaoflow ]; | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-28 16:03:47 +01:00
										 |  |  |   nodes = let | 
					
						
							| 
									
										
										
										
											2018-07-20 20:56:59 +00:00
										 |  |  |     cfg = { ... }: { | 
					
						
							| 
									
										
										
										
											2016-02-28 16:03:47 +01:00
										 |  |  |       services.avahi = { | 
					
						
							|  |  |  |         enable = true; | 
					
						
							|  |  |  |         nssmdns = true; | 
					
						
							|  |  |  |         publish.addresses = true; | 
					
						
							|  |  |  |         publish.domain = true; | 
					
						
							|  |  |  |         publish.enable = true; | 
					
						
							|  |  |  |         publish.userServices = true; | 
					
						
							|  |  |  |         publish.workstation = true; | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  |       }; | 
					
						
							| 
									
										
										
										
											2016-02-28 16:03:47 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  |   in { | 
					
						
							|  |  |  |     one = cfg; | 
					
						
							|  |  |  |     two = cfg; | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   testScript = | 
					
						
							|  |  |  |     '' startAll;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        # mDNS. | 
					
						
							| 
									
										
										
										
											2012-10-24 18:22:53 +02:00
										 |  |  |        $one->waitForUnit("network.target"); | 
					
						
							| 
									
										
										
										
											2014-04-08 18:43:58 +02:00
										 |  |  |        $two->waitForUnit("network.target"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-24 18:22:53 +02:00
										 |  |  |        $one->succeed("avahi-resolve-host-name one.local | tee out >&2"); | 
					
						
							|  |  |  |        $one->succeed("test \"`cut -f1 < out`\" = one.local"); | 
					
						
							|  |  |  |        $one->succeed("avahi-resolve-host-name two.local | tee out >&2"); | 
					
						
							|  |  |  |        $one->succeed("test \"`cut -f1 < out`\" = two.local"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |        $two->succeed("avahi-resolve-host-name one.local | tee out >&2"); | 
					
						
							|  |  |  |        $two->succeed("test \"`cut -f1 < out`\" = one.local"); | 
					
						
							|  |  |  |        $two->succeed("avahi-resolve-host-name two.local | tee out >&2"); | 
					
						
							|  |  |  |        $two->succeed("test \"`cut -f1 < out`\" = two.local"); | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |        # Basic DNS-SD. | 
					
						
							| 
									
										
										
										
											2012-10-24 18:22:53 +02:00
										 |  |  |        $one->succeed("avahi-browse -r -t _workstation._tcp | tee out >&2"); | 
					
						
							|  |  |  |        $one->succeed("test `wc -l < out` -gt 0"); | 
					
						
							|  |  |  |        $two->succeed("avahi-browse -r -t _workstation._tcp | tee out >&2"); | 
					
						
							|  |  |  |        $two->succeed("test `wc -l < out` -gt 0"); | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |        # More DNS-SD. | 
					
						
							|  |  |  |        $one->execute("avahi-publish -s \"This is a test\" _test._tcp 123 one=1 &"); | 
					
						
							| 
									
										
										
										
											2011-01-10 14:41:16 +00:00
										 |  |  |        $one->sleep(5); | 
					
						
							| 
									
										
										
										
											2012-10-24 18:22:53 +02:00
										 |  |  |        $two->succeed("avahi-browse -r -t _test._tcp | tee out >&2"); | 
					
						
							|  |  |  |        $two->succeed("test `wc -l < out` -gt 0"); | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |        # NSS-mDNS. | 
					
						
							| 
									
										
										
										
											2012-10-24 18:22:53 +02:00
										 |  |  |        $one->succeed("getent hosts one.local >&2"); | 
					
						
							|  |  |  |        $one->succeed("getent hosts two.local >&2"); | 
					
						
							|  |  |  |        $two->succeed("getent hosts one.local >&2"); | 
					
						
							|  |  |  |        $two->succeed("getent hosts two.local >&2"); | 
					
						
							| 
									
										
										
										
											2010-10-07 16:58:07 +00:00
										 |  |  |     '';
 | 
					
						
							| 
									
										
										
										
											2015-07-12 12:09:40 +02:00
										 |  |  | }) |