Skip to content

Commit

Permalink
Fix license headers in new files
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 3, 2016
1 parent 1f97e00 commit 266962f
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 78 deletions.
22 changes: 15 additions & 7 deletions tests/host/common/Arduino.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
//
// Arduino.cpp
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 02/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//
/*
Arduino.cpp - Mocks for common Arduino APIs
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/

#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <sys/time.h>
Expand Down
25 changes: 18 additions & 7 deletions tests/host/common/Arduino.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
//
// Arduino.hpp
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 02/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef Arduino_h
#define Arduino_h
Expand Down
72 changes: 37 additions & 35 deletions tests/host/common/pgmspace.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
pgmspace.cpp - PROGMEM stubs for host-side tests
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/
#ifndef __PGMSPACE_H_
#define __PGMSPACE_H_

Expand All @@ -7,7 +21,7 @@
#define PROGMEM
#define PGM_P const char *
#define PGM_VOID_P const void *
#define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
#define PSTR(s) (s)


#define _SFR_BYTE(n) (n)
Expand All @@ -22,47 +36,35 @@ typedef uint16_t prog_uint16_t;
typedef int32_t prog_int32_t;
typedef uint32_t prog_uint32_t;

#define SIZE_IRRELEVANT 0x7fffffff
#define memcmp_P memcmp
#define memccpy_P memccpy
#define memmem_P memmem
#define memcpy_P memcpy

#define strncpy_P strncpy
#define strcpy_P strcpy

int memcmp_P(const void* buf1, PGM_VOID_P buf2P, size_t size);
// memccpy_P is only valid when used with pointers to 8bit data, due to size aligned pointers
// and endianess of the values greater than 8bit, matching c may return invalid aligned pointers
void* memccpy_P(void* dest, PGM_VOID_P src, int c, size_t count);
void* memmem_P(const void* buf, size_t bufSize, PGM_VOID_P findP, size_t findPSize);
void* memcpy_P(void* dest, PGM_VOID_P src, size_t count);
#define strncat_P strncat
#define strcat_P strcat

#define strncpy_P(dest, src, size) strncpy(dest, src, size)
#define strcpy_P(dest, src) strncpy_P((dest), (src), SIZE_IRRELEVANT)
#define strncmp_P strncmp
#define strcmp_P strcmp

#define strncat_P(dest, src, size) strncat(dest, src, size)
#define strcat_P(dest, src) strncat_P((dest), (src), SIZE_IRRELEVANT)
#define strncasecmp_P strncasecmp
#define strcasecmp_P strcasecmp

#define strncmp_P(str1, str2P, size) strncmp(str1, str2P, size)
#define strcmp_P(str1, str2P) strncmp_P((str1), (str2P), SIZE_IRRELEVANT)
#define strnlen_P strnlen
#define strlen_P strlen

#define strncasecmp_P(str1, str2P, size) strncasecmp(str1, str2P, size)
#define strcasecmp_P(str1, str2P) strncasecmp_P((str1), (str2P), SIZE_IRRELEVANT)
#define printf_P printf
#define sprintf_P sprintf
#define snprintf_P snprintf
#define vsnprintf_P vsnprintf

#define strnlen_P(s, size) strnlen(s, size)
#define strlen_P(strP) strnlen_P((strP), SIZE_IRRELEVANT)

#define printf_P(formatP, ...) printf(formatP, __VA_ARGS__)
#define sprintf_P(str, formatP, ...) sprintf(str, formatP, __VA_ARGS__)
#define snprintf_P(str, strSize, formatP, ...) snprintf(str, strSize, formatP, __VA_ARGS__)
#define vsnprintf_P(str, strSize, formatP, ap) vsnprintf(str, strSize, formatP, ap)

// flash memory must be read using 32 bit aligned addresses else a processor
// exception will be triggered
// order within the 32 bit values are
// --------------
// b3, b2, b1, b0
// w1, w0

#define pgm_read_byte(x) (*reinterpret_cast<const uint8_t*>(x))
#define pgm_read_word(x) (*reinterpret_cast<const uint16_t*>(x))
#define pgm_read_float(x) (*reinterpret_cast<const float*>(x))
#define pgm_read_dword(x) (*reinterpret_cast<const uint32_t*>(x))
#define pgm_read_byte(addr) (*reinterpret_cast<const uint8_t*>(addr))
#define pgm_read_word(addr) (*reinterpret_cast<const uint16_t*>(addr))
#define pgm_read_float(addr) (*reinterpret_cast<const float*>(addr))
#define pgm_read_dword(addr) (*reinterpret_cast<const uint32_t*>(addr))

#define pgm_read_byte_near(addr) pgm_read_byte(addr)
#define pgm_read_word_near(addr) pgm_read_word(addr)
Expand Down
22 changes: 14 additions & 8 deletions tests/host/common/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
//
// pins_arduino.h
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 02/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//

/*
pins_arduino.h
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/
#ifndef pins_arduino_h
#define pins_arduino_h

Expand Down
22 changes: 15 additions & 7 deletions tests/host/common/spiffs_mock.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
//
// spiffs_mock.cpp
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 03/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//
/*
spiffs_mock.cpp - SPIFFS HAL mock for host side testing
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/


#include "spiffs_mock.h"
#include "spiffs/spiffs.h"
Expand Down
21 changes: 14 additions & 7 deletions tests/host/common/spiffs_mock.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
//
// spiffs_mock.hpp
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 03/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//
/*
spiffs_mock.h - SPIFFS HAL mock for host side testing
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/

#ifndef spiffs_mock_hpp
#define spiffs_mock_hpp
Expand Down
21 changes: 14 additions & 7 deletions tests/host/fs/test_fs.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
//
// test_fs.cpp
// esp8266-host-tests
//
// Created by Ivan Grokhotkov on 02/03/16.
// Copyright © 2016 esp8266.com. All rights reserved.
//
/*
test_fs.cpp - host side file system tests
Copyright © 2016 Ivan Grokhotkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/

#include <catch.hpp>
#include <FS.h>
Expand Down

0 comments on commit 266962f

Please sign in to comment.