annotate packages/net/sntp/current/tests/sntp1.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents 16a975af0355
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
1 //=================================================================
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
2 //
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
3 // sntp1.c
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
4 //
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
5 // Simple Network Time Protocol test 1
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
6 //
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
11 // Copyright (C) 2003 Free Software Foundation, Inc.
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
16 // version.
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
21 // for more details.
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
33 // General Public License v2.
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 1323
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
39 //==========================================================================
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
41 //
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
42 // Author(s): Andrew Lunn
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
43 // Contributors:
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
44 // Date: 2003-02-11
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
45 // Description: Tests the sntp client
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
46 //####DESCRIPTIONEND####
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
47
759
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
48 #include <pkgconf/isoinfra.h>
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
49 #include <cyg/infra/testcase.h>
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
50
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
51 #if defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS)
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
52 #include <network.h>
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
53 #include <time.h>
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
54 #include <cyg/sntp/sntp.h>
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
55 #include <stdio.h>
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
56
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
57 #define SECONDSPERMINUTE (cyg_uint32)60
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
58 #define SECONDSPERHOUR (cyg_uint32)(SECONDSPERMINUTE * 60)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
59 #define SECONDSPERDAY (cyg_uint32)(SECONDSPERHOUR * 24)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
60 #define SECONDSPERYEAR (cyg_uint32)(SECONDSPERDAY * 365)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
61
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
62 void
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
63 net_test(cyg_addrword_t param)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
64 {
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
65 int seconds;
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
66 time_t now, build_time;
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
67 struct tm tm={ 0,0,0,0,0,0,0,0,0 };
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
68 int i, loop, waittime;
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
69 char month[4];
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
70 char months[12][4] = { "Jan", "Feb", "Mar",
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
71 "Apr", "May", "Jun",
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
72 "Jul", "Aug", "Sep",
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
73 "Oct", "Nov", "Dec" };
759
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
74 char time_info[32];
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
75
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
76 CYG_TEST_INIT();
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
77
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
78 CYG_TEST_INFO("sntp1 test build " __DATE__);
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
79
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
80 init_all_network_interfaces();
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
81
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
82 cyg_sntp_start();
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
83
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
84 /* The SNTP client will try to obtain NTP time updates by
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
85 * listening for multicasts. It can also be configured
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
86 * to send unicast requests to specific NTP servers. By
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
87 * default, unicast NTP servers are obtained from DHCP.
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
88 *
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
89 * If unicast mode is enabled, the run the test loop twice.
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
90 * The first time, unicast requests will be sent. The
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
91 * second time, the unicast list will be unconfigured and
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
92 * the client will listen only for multicasts.
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
93 *
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
94 * Note that this test is somewhat bogus since multicast
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
95 * NTP packets will actually allow both test loops to
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
96 * pass. But it is the best we can do for the automated
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
97 * test, so consider this more of a usage example.
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
98 */
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
99 #ifdef CYGPKG_NET_SNTP_UNICAST
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
100 loop = 2;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
101 #else
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
102 loop = 1;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
103 #endif
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
104 while (loop-- > 0)
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
105 {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
106 if (loop == 1) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
107 CYG_TEST_INFO("Testing SNTP unicast mode.");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
108 waittime=14;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
109 } else {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
110 CYG_TEST_INFO("Testing SNTP multicast mode.");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
111 waittime=20;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
112 }
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
113 for (seconds = waittime; seconds > 0; seconds--) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
114 now = time(NULL);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
115 ctime_r(&now, time_info);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
116 time_info[strlen(time_info)-1] = '\0'; // Strip \n
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
117 CYG_TEST_INFO(time_info);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
118 cyg_thread_delay(100);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
119 }
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
120
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
121 now = time(NULL);
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
122
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
123 if ( now < (5 * 60)) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
124 CYG_TEST_FAIL_FINISH("Nothing recieved from the SNTP server");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
125 } else {
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
126
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
127 i=sscanf(__DATE__, "%s %d %d",month,&tm.tm_mday,&tm.tm_year);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
128 CYG_ASSERT(3==i,"sscanf did not return enough results");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
129 for (i=0; i < 12; i++) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
130 if (!strcmp(month,months[i]))
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
131 break;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
132 }
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
133 tm.tm_mon = i;
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
134 tm.tm_year -= 1900;
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
135
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
136 build_time = mktime(&tm);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
137 CYG_ASSERT(-1 != build_time,"mktime returned -1");
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
138
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
139 if (build_time > time(NULL)) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
140 CYG_TEST_FAIL_FINISH("Build time is ahead of SNTP time");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
141 } else {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
142 if ((build_time + 60 * 60 * 24 * 90) < time(NULL)) {
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
143 CYG_TEST_FAIL_FINISH("Build time is more than 90 days old");
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
144 }
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
145 }
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
146 }
1323
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
147
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
148 #ifdef CYGPKG_NET_SNTP_UNICAST
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
149 /* For the second pass of the test, we set the time
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
150 * back to epoch and unconfigure the list of SNTP
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
151 * unicast servers. This will test non-unicast mode.
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
152 */
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
153 cyg_sntp_set_servers(NULL, 0);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
154 cyg_libc_time_settime(0);
16a975af0355 * src/sntp.c: Added DHCP support for SNTP unicast mode.
asl
parents: 1033
diff changeset
155 #endif
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
156 }
759
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
157 CYG_TEST_PASS_FINISH("sntp1 test is complete");
748
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
158 }
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
159
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
160 #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL*2)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
161 static char thread_stack[STACK_SIZE];
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
162 static cyg_thread thread_data;
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
163 static cyg_handle_t thread_handle;
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
164
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
165 void
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
166 cyg_user_start(void)
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
167 {
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
168 // Create a main thread, so we can run the scheduler and have time 'pass'
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
169 cyg_thread_create(10, // Priority - just a number
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
170 net_test, // entry
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
171 0, // entry parameter
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
172 "Network test", // Name
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
173 thread_stack, // Stack
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
174 STACK_SIZE, // Size
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
175 &thread_handle, // Handle
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
176 &thread_data // Thread data structure
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
177 );
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
178 cyg_thread_resume(thread_handle); // Start it
d21da3c91474 First import of the Simple Network Time Protocol client.
asl
parents:
diff changeset
179 }
759
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
180
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
181 #else //defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS)
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
182
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
183 void cyg_user_start(void)
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
184 {
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
185 CYG_TEST_NA("Not all the required packages are available");
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
186 }
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
187
018143c925ee * tests/sntp1.c (net_test): Strip the trailing "\n" making it more
asl
parents: 748
diff changeset
188 #endif