public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [testsuite, AVR]: Add some progmem test cases
@ 2011-06-30 18:03 Georg-Johann Lay
  2011-06-30 21:36 ` Georg-Johann Lay
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Georg-Johann Lay @ 2011-06-30 18:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Anatoly Sokolov, Denis Chertykov, Eric Weddington

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

Some runtime and checks for error/warning for C/C++.

Is
  ./testsuite/gcc.target/avr/
realm of avr port maintainers?

Johann

testsuite/
	* gcc.target/avr/avr.exp: Run over cpp files, too.
	* gcc.target/avr/torture/avr-torture.exp: Ditto.
	* gcc.target/avr/progmem-error-1.c: New file.
	* gcc.target/avr/progmem-error-1.cpp: New file.
	* gcc.target/avr/progmem-warning-1.c: New file.
	* gcc.target/avr/torture/progmem-1.c: New file.
	* gcc.target/avr/torture/progmem-1.cpp: New file.
	* gcc.target/avr/torture/progmem.h: New file.
	* gcc.target/avr/torture/exit-abort.h: New file.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-progmem.diff --]
[-- Type: text/x-patch; name="test-progmem.diff", Size: 4366 bytes --]

Index: gcc.target/avr/avr.exp
===================================================================
--- gcc.target/avr/avr.exp	(revision 175628)
+++ gcc.target/avr/avr.exp	(working copy)
@@ -34,7 +34,7 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cCS\],cpp}]] \
 	"" $DEFAULT_CFLAGS
 
 # All done.
Index: gcc.target/avr/torture/exit-abort.h
===================================================================
--- gcc.target/avr/torture/exit-abort.h	(revision 0)
+++ gcc.target/avr/torture/exit-abort.h	(revision 0)
@@ -0,0 +1,8 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+  extern void exit (int);
+  extern void abort (void);
+#ifdef __cplusplus
+}
+#endif
Index: gcc.target/avr/torture/avr-torture.exp
===================================================================
--- gcc.target/avr/torture/avr-torture.exp	(revision 175628)
+++ gcc.target/avr/torture/avr-torture.exp	(working copy)
@@ -52,7 +52,7 @@ set-torture-options $AVR_TORTURE_OPTIONS
 
 
 # Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] $DEFAULT_CFLAGS
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cS\],cpp}]] $DEFAULT_CFLAGS
 
 # Finalize use of torture lists.
 torture-finish
Index: gcc.target/avr/torture/progmem-1.c
===================================================================
--- gcc.target/avr/torture/progmem-1.c	(revision 0)
+++ gcc.target/avr/torture/progmem-1.c	(revision 0)
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+#include "exit-abort.h"
+#include "progmem.h"
+
+const char strA[] PROGMEM = "@A";
+const char strc PROGMEM = 'c';
+
+unsigned int volatile s = 2;
+
+int main()
+{
+    char c;
+    
+    c = pgm_read_char (&strA[s-1]);
+    if (c != 'A')
+        abort();
+
+    c = pgm_read_char (&PSTR ("@@B")[s]);
+    if (c != 'B')
+        abort();
+
+    c = pgm_read_char (&strc);
+    if (c != 'c')
+        abort();
+
+    exit (0);
+
+    return 0;
+}
Index: gcc.target/avr/torture/progmem-1.cpp
===================================================================
--- gcc.target/avr/torture/progmem-1.cpp	(revision 0)
+++ gcc.target/avr/torture/progmem-1.cpp	(revision 0)
@@ -0,0 +1,2 @@
+/* { dg-do run } */
+#include "progmem-1.c"
Index: gcc.target/avr/torture/progmem.h
===================================================================
--- gcc.target/avr/torture/progmem.h	(revision 0)
+++ gcc.target/avr/torture/progmem.h	(revision 0)
@@ -0,0 +1,14 @@
+#define PROGMEM __attribute__((progmem))
+
+#define PSTR(s)                                             \
+    (__extension__({                                        \
+            static const char __c[] PROGMEM = (s);          \
+            &__c[0];}))
+
+#define pgm_read_char(addr)                                 \
+    (__extension__({                                        \
+            unsigned int __addr16 = (unsigned int)(addr);   \
+            char __result;                                  \
+            __asm__ ("lpm %0, %a1"                          \
+                     : "=r" (__result) : "z" (__addr16));   \
+            __result; }))
Index: gcc.target/avr/progmem-warning-1.c
===================================================================
--- gcc.target/avr/progmem-warning-1.c	(revision 0)
+++ gcc.target/avr/progmem-warning-1.c	(revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+#include "torture/progmem.h"
+
+const char c PROGMEM; /* { dg-warning "uninitialized variable 'c' put into program memory area" } */
Index: gcc.target/avr/progmem-error-1.c
===================================================================
--- gcc.target/avr/progmem-error-1.c	(revision 0)
+++ gcc.target/avr/progmem-error-1.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "torture/progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
Index: gcc.target/avr/progmem-error-1.cpp
===================================================================
--- gcc.target/avr/progmem-error-1.cpp	(revision 0)
+++ gcc.target/avr/progmem-error-1.cpp	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "torture/progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [testsuite, AVR]: Add some progmem test cases
  2011-06-30 18:03 [testsuite, AVR]: Add some progmem test cases Georg-Johann Lay
@ 2011-06-30 21:36 ` Georg-Johann Lay
  2011-07-04 10:20 ` Ping #1: " Georg-Johann Lay
  2011-07-04 17:56 ` Mike Stump
  2 siblings, 0 replies; 6+ messages in thread
From: Georg-Johann Lay @ 2011-06-30 21:36 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: gcc-patches, Anatoly Sokolov, Denis Chertykov, Eric Weddington

Georg-Johann Lay schrieb:
> Some runtime and checks for error/warning for C/C++.
> 
...
> testsuite/
> 	* gcc.target/avr/torture/progmem.h: New file.
> 	* gcc.target/avr/torture/exit-abort.h: New file.

maybe it's better to have the .h files one level up like so?

  	* gcc.target/avr/progmem.h: New file.
  	* gcc.target/avr/exit-abort.h: New file.

For better accessibility in upcoming tests.

Johann

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Ping #1: [testsuite, AVR]: Add some progmem test cases
  2011-06-30 18:03 [testsuite, AVR]: Add some progmem test cases Georg-Johann Lay
  2011-06-30 21:36 ` Georg-Johann Lay
@ 2011-07-04 10:20 ` Georg-Johann Lay
  2011-07-04 11:08   ` Denis Chertykov
  2011-07-04 17:56 ` Mike Stump
  2 siblings, 1 reply; 6+ messages in thread
From: Georg-Johann Lay @ 2011-07-04 10:20 UTC (permalink / raw)
  To: gcc-patches; +Cc: Anatoly Sokolov, Denis Chertykov, Eric Weddington

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

Georg-Johann Lay wrote:
> Some runtime and checks for error/warning for C/C++.

Note that some tests fail because of pending

http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02318.html

Johann

testsuite/
	* gcc.target/avr/avr.exp: Run over cpp files, too.
	* gcc.target/avr/torture/avr-torture.exp: Ditto.
	* gcc.target/avr/progmem.h: New file.
	* gcc.target/avr/exit-abort.h: New file.
	* gcc.target/avr/progmem-error-1.c: New file.
	* gcc.target/avr/progmem-error-1.cpp: New file.
	* gcc.target/avr/progmem-warning-1.c: New file.
	* gcc.target/avr/torture/progmem-1.c: New file.
	* gcc.target/avr/torture/progmem-1.cpp: New file.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-progmem.diff --]
[-- Type: text/x-patch; name="test-progmem.diff", Size: 4300 bytes --]

Index: gcc.target/avr/avr.exp
===================================================================
--- gcc.target/avr/avr.exp	(revision 175628)
+++ gcc.target/avr/avr.exp	(working copy)
@@ -34,7 +34,7 @@ if ![info exists DEFAULT_CFLAGS] then {
 dg-init
 
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cCS\],cpp}]] \
 	"" $DEFAULT_CFLAGS
 
 # All done.
Index: gcc.target/avr/torture/avr-torture.exp
===================================================================
--- gcc.target/avr/torture/avr-torture.exp	(revision 175628)
+++ gcc.target/avr/torture/avr-torture.exp	(working copy)
@@ -52,7 +52,7 @@ set-torture-options $AVR_TORTURE_OPTIONS
 
 
 # Main loop.
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] $DEFAULT_CFLAGS
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cS\],cpp}]] $DEFAULT_CFLAGS
 
 # Finalize use of torture lists.
 torture-finish
Index: gcc.target/avr/torture/progmem-1.c
===================================================================
--- gcc.target/avr/torture/progmem-1.c	(revision 0)
+++ gcc.target/avr/torture/progmem-1.c	(revision 0)
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+#include "../exit-abort.h"
+#include "../progmem.h"
+
+const char strA[] PROGMEM = "@A";
+const char strc PROGMEM = 'c';
+
+unsigned int volatile s = 2;
+
+int main()
+{
+    char c;
+    
+    c = pgm_read_char (&strA[s-1]);
+    if (c != 'A')
+        abort();
+
+    c = pgm_read_char (&PSTR ("@@B")[s]);
+    if (c != 'B')
+        abort();
+
+    c = pgm_read_char (&strc);
+    if (c != 'c')
+        abort();
+
+    exit (0);
+
+    return 0;
+}
Index: gcc.target/avr/torture/progmem-1.cpp
===================================================================
--- gcc.target/avr/torture/progmem-1.cpp	(revision 0)
+++ gcc.target/avr/torture/progmem-1.cpp	(revision 0)
@@ -0,0 +1,2 @@
+/* { dg-do run } */
+#include "progmem-1.c"
Index: gcc.target/avr/exit-abort.h
===================================================================
--- gcc.target/avr/exit-abort.h	(revision 0)
+++ gcc.target/avr/exit-abort.h	(revision 0)
@@ -0,0 +1,8 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+  extern void exit (int);
+  extern void abort (void);
+#ifdef __cplusplus
+}
+#endif
Index: gcc.target/avr/progmem-warning-1.c
===================================================================
--- gcc.target/avr/progmem-warning-1.c	(revision 0)
+++ gcc.target/avr/progmem-warning-1.c	(revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+#include "progmem.h"
+
+const char c PROGMEM; /* { dg-warning "uninitialized variable 'c' put into program memory area" } */
Index: gcc.target/avr/progmem-error-1.c
===================================================================
--- gcc.target/avr/progmem-error-1.c	(revision 0)
+++ gcc.target/avr/progmem-error-1.c	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
Index: gcc.target/avr/progmem-error-1.cpp
===================================================================
--- gcc.target/avr/progmem-error-1.cpp	(revision 0)
+++ gcc.target/avr/progmem-error-1.cpp	(revision 0)
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
Index: gcc.target/avr/progmem.h
===================================================================
--- gcc.target/avr/progmem.h	(revision 0)
+++ gcc.target/avr/progmem.h	(revision 0)
@@ -0,0 +1,14 @@
+#define PROGMEM __attribute__((progmem))
+
+#define PSTR(s)                                             \
+    (__extension__({                                        \
+            static const char __c[] PROGMEM = (s);          \
+            &__c[0];}))
+
+#define pgm_read_char(addr)                                 \
+    (__extension__({                                        \
+            unsigned int __addr16 = (unsigned int)(addr);   \
+            char __result;                                  \
+            __asm__ ("lpm %0, %a1"                          \
+                     : "=r" (__result) : "z" (__addr16));   \
+            __result; }))

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping #1: [testsuite, AVR]: Add some progmem test cases
  2011-07-04 10:20 ` Ping #1: " Georg-Johann Lay
@ 2011-07-04 11:08   ` Denis Chertykov
  2011-07-04 18:01     ` Mike Stump
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Chertykov @ 2011-07-04 11:08 UTC (permalink / raw)
  To: Georg-Johann Lay; +Cc: gcc-patches, Anatoly Sokolov, Eric Weddington

2011/7/4 Georg-Johann Lay <avr@gjlay.de>:
> Georg-Johann Lay wrote:
>> Some runtime and checks for error/warning for C/C++.
>
> Note that some tests fail because of pending
>
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02318.html
>
> Johann
>
> testsuite/
>        * gcc.target/avr/avr.exp: Run over cpp files, too.
>        * gcc.target/avr/torture/avr-torture.exp: Ditto.
>        * gcc.target/avr/progmem.h: New file.
>        * gcc.target/avr/exit-abort.h: New file.
>        * gcc.target/avr/progmem-error-1.c: New file.
>        * gcc.target/avr/progmem-error-1.cpp: New file.
>        * gcc.target/avr/progmem-warning-1.c: New file.
>        * gcc.target/avr/torture/progmem-1.c: New file.
>        * gcc.target/avr/torture/progmem-1.cpp: New file.

I don't know who must approve tests.
If me then Approved

Denis.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [testsuite, AVR]: Add some progmem test cases
  2011-06-30 18:03 [testsuite, AVR]: Add some progmem test cases Georg-Johann Lay
  2011-06-30 21:36 ` Georg-Johann Lay
  2011-07-04 10:20 ` Ping #1: " Georg-Johann Lay
@ 2011-07-04 17:56 ` Mike Stump
  2 siblings, 0 replies; 6+ messages in thread
From: Mike Stump @ 2011-07-04 17:56 UTC (permalink / raw)
  To: Georg-Johann Lay
  Cc: gcc-patches, Anatoly Sokolov, Denis Chertykov, Eric Weddington

On Jun 30, 2011, at 10:38 AM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Is
>  ./testsuite/gcc.target/avr/
> realm of avr port maintainers?

I'm fine with the avr people reviewing and approving all they think is ready for the tree.  If they go out into the weeds, we can reign them in, I'm sure that would never happen.  If a port is lacking in review bandwidth, I might fire up, but I don't think avr fits that description.
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ping #1: [testsuite, AVR]: Add some progmem test cases
  2011-07-04 11:08   ` Denis Chertykov
@ 2011-07-04 18:01     ` Mike Stump
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Stump @ 2011-07-04 18:01 UTC (permalink / raw)
  To: Denis Chertykov
  Cc: Georg-Johann Lay, gcc-patches, Anatoly Sokolov, Eric Weddington

On Jul 4, 2011, at 4:07 AM, Denis Chertykov <chertykov@gmail.com> wrote:
>> 
>> testsuite/

>>        * gcc.target/avr/torture/progmem-1.cpp: New file.
> 
> I don't know who must approve tests.
> If me then Approved

You!   If there are ugly details more related to the test suite framework, feel free to kick it up.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-04 18:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 18:03 [testsuite, AVR]: Add some progmem test cases Georg-Johann Lay
2011-06-30 21:36 ` Georg-Johann Lay
2011-07-04 10:20 ` Ping #1: " Georg-Johann Lay
2011-07-04 11:08   ` Denis Chertykov
2011-07-04 18:01     ` Mike Stump
2011-07-04 17:56 ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).