1266989Smarkj/*
2266989Smarkj * This file and its contents are supplied under the terms of the
3266989Smarkj * Common Development and Distribution License ("CDDL"), version 1.0.
4266989Smarkj * You may only use this file in accordance with the terms of version
5266989Smarkj * 1.0 of the CDDL.
6266989Smarkj *
7266989Smarkj * A full copy of the text of the CDDL should have accompanied this
8266989Smarkj * source.  A copy of the CDDL is also available via the Internet at
9266989Smarkj * http://www.illumos.org/license/CDDL.
10266989Smarkj */
11266989Smarkj
12266989Smarkj/*
13266989Smarkj * Copyright 2013 (c) Joyent, Inc. All rights reserved.
14266989Smarkj */
15266989Smarkj
16266989Smarkj/*
17266989Smarkj * This test takes data from the current binary which is basically running in a
18266989Smarkj * loop between two functions and our goal is to have two unique types that they
19266989Smarkj * contain which we can print.
20266989Smarkj */
21266989Smarkj
22266989Smarkj#include <unistd.h>
23266989Smarkj
24266989Smarkjtypedef struct zelda_info {
25266989Smarkj	char	*zi_gamename;
26266989Smarkj	int	zi_ndungeons;
27266989Smarkj	char	*zi_villain;
28266989Smarkj	int	zi_haszelda;
29266989Smarkj} zelda_info_t;
30266989Smarkj
31266989Smarkjstatic int
32266989Smarkjhas_princess(zelda_info_t *z)
33266989Smarkj{
34266989Smarkj	return (z->zi_haszelda);
35266989Smarkj}
36266989Smarkj
37266989Smarkjstatic int
38266989Smarkjhas_dungeons(zelda_info_t *z)
39266989Smarkj{
40266989Smarkj	return (z->zi_ndungeons != 0);
41266989Smarkj}
42266989Smarkj
43266989Smarkjstatic const char *
44266989Smarkjhas_villain(zelda_info_t *z)
45266989Smarkj{
46266989Smarkj	return (z->zi_villain);
47266989Smarkj}
48266989Smarkj
49266989Smarkjint
50266989Smarkjmain(void)
51266989Smarkj{
52266989Smarkj	zelda_info_t oot;
53266989Smarkj	zelda_info_t la;
54266989Smarkj	zelda_info_t lttp;
55266989Smarkj
56266989Smarkj	oot.zi_gamename = "Ocarina of Time";
57266989Smarkj	oot.zi_ndungeons = 10;
58266989Smarkj	oot.zi_villain = "Ganondorf";
59266989Smarkj	oot.zi_haszelda = 1;
60266989Smarkj
61266989Smarkj	la.zi_gamename = "Link's Awakening";
62266989Smarkj	la.zi_ndungeons = 9;
63266989Smarkj	la.zi_villain = "Nightmare";
64266989Smarkj	la.zi_haszelda = 0;
65266989Smarkj
66266989Smarkj	lttp.zi_gamename = "A Link to the Past";
67266989Smarkj	lttp.zi_ndungeons = 12;
68266989Smarkj	lttp.zi_villain = "Ganon";
69266989Smarkj	lttp.zi_haszelda = 1;
70266989Smarkj
71266989Smarkj	for (;;) {
72266989Smarkj		(void) has_princess(&oot);
73266989Smarkj		(void) has_dungeons(&la);
74266989Smarkj		(void) has_villain(&lttp);
75266989Smarkj		sleep(1);
76266989Smarkj	}
77266989Smarkj
78266989Smarkj	return (0);
79266989Smarkj}
80