Commit graph

187 commits

Author SHA1 Message Date
def 41910ff5fd Add sqliteversion test 2021-12-19 19:40:20 +01:00
def 010ecd0868 More output in score test 2021-12-19 19:40:20 +01:00
def baf9b94f2c Factor CScoreWorker out of CScore, add SaveScore test 2021-12-19 19:40:20 +01:00
heinrich5991 49c861372a Add a flag to skip a UTF-8 BOM when opening files for reading
https://en.wikipedia.org/w/index.php?title=Byte_order_mark&oldid=1059783325#UTF-8

This allows to read text files created by Windows users transparently,
even if they contain a UTF-8 BOM.
2021-12-17 22:07:01 +01:00
bors[bot] d862207a73
Merge #4405
4405: Try to use unique_ptr in tests so we can't forget to delete r=heinrich5991 a=def-

Why is the PingCache test failing now???

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2021-12-10 02:53:55 +00:00
Robert Müller f20443b694 fix command line arguments with unicode on windows
Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-12-06 19:48:25 +01:00
def 4ac5ca1449 Try to use unique_ptr in tests so we can't forget to delete 2021-11-29 00:40:10 +01:00
def 87a089c4aa test/serverbrowser: delete pConsole
==235823==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 65632 byte(s) in 1 object(s) allocated from:
    #0 0x563636cc2fc9 in malloc (/media/ddnet/testrunner+0x37afc9)
    #1 0x563636e0fd89 in CHeap::NewChunk() /media/ddnet/src/engine/shared/memheap.cpp:14:17
    #2 0x563636e10aee in CHeap::Reset() /media/ddnet/src/engine/shared/memheap.cpp:63:2
    #3 0x563636d954a5 in CConsole::CExecutionQueue::Reset() /media/ddnet/src/engine/shared/console.h:188:12
    #4 0x563636d4a272 in CConsole::CConsole(int) /media/ddnet/src/engine/shared/console.cpp:937:19
    #5 0x563636d88a98 in CreateConsole(int) /media/ddnet/src/engine/shared/console.cpp:1230:59
    #6 0x563636fbe915 in ServerBrowser_PingCache_Test::TestBody() /media/ddnet/src/test/serverbrowser.cpp:13:23
    #7 0x7f0a2f87fe26 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/usr/lib/libgtest.so.1.11.0+0x54e26)
2021-11-28 15:51:31 +01:00
Robert Müller 84ecbdb9d0 add str_utf8_stats to base system 2021-11-24 23:24:46 +01:00
heinrich5991 1bffc6ebfc teehistorian: Test statefulness of PLAYER_TEAM and TEAM_PRACTICE 2021-10-06 18:06:19 +02:00
heinrich5991 fbb98c8801 teehistorian: Test no-op function calls as well 2021-10-06 17:33:22 +02:00
bors[bot] 121c6d16f6
Merge #3879 #4079
3879: Use SDL_FlashWindow to request user's attention r=heinrich5991 a=Jupeyy

We should soon update to SDL 2.0.16 for our bundled libs, but don't merge before this happened.

This drops the remaining X11 dependency.

We should then also use GLEW with EGL for official builds for easy native wayland support(which i discussed before already)

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


4079: Make teehistorian easier to reproduce r=heinrich5991 a=Zwelf

I've tested it ingame, but still have to make sure, that the ordering of the teehistorian messages are right. I would be really happy if we could land this before changing team joining logic (#4006 or /practice logic, but there isn't a pr for this yet), but I would like to make sure that the change is correct.

## Checklist

- [x] Tested the change ingame
- [ ] Tested in combination with possibly related configuration options
- [x] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: Zwelf <zwelf@strct.cc>
2021-10-06 14:52:39 +00:00
Zwelf e9dec007b2 Address review to make code more consistent 2021-09-15 17:31:35 +02:00
Zwelf 81f4263428 Record team practice mode making replay easier 2021-09-14 22:10:43 +02:00
heinrich5991 9b4b0cd4eb Remove a #include <base/system.h>
The variable isn't actually a path, just the test name formatted as file
name, so the 64 isn't actually too strict.
2021-09-13 12:40:40 +02:00
ChillerDragon 3eb3dcd48b Make use of IO_MAX_PATH_LENGTH
Inspired by
0a7d0fee7c
2021-09-13 12:14:50 +02:00
Zwelf d6912f7ced Record team change in teehistorian 2021-08-14 15:22:13 +02:00
Zwelf 6c452c15cf Record tee position at the end of the tick
priviously spawning players were recorded one tick too late
and add teehistorian minor version for the validator to recognize the
change
2021-08-14 15:22:13 +02:00
heinrich5991 1f68e11445 Mark the inverted exclamation mark as confusable with i
They look pretty much the same in our font, but for some reason, the
inverted exclamation mark doesn't have confusables.
2021-07-27 02:43:04 +02:00
Vlad af3de10e72
Enable related tests 2021-07-26 13:48:12 +03:00
Jupeyy a663799188 uint64 -> uint64_t, int64 -> int64_t 2021-06-24 17:19:17 +02:00
def f5c2748552 Fix test.cpp compilation 2021-06-20 11:30:42 +02:00
heinrich5991 f5e91ba192 Remove unused parts of the new serverinfo 2021-05-27 21:48:10 +02:00
heinrich5991 9eca91de74 Special case China as its own continent for ping estimation
It has an exceptionally bad connection to the outside due to the Great
Firewall of China:
https://en.wikipedia.org/w/index.php?title=Great_Firewall&oldid=1019589632
2021-05-14 01:01:08 +02:00
heinrich5991 bce7a4f84e Add serverbrowser ping cache 2021-05-14 01:00:41 +02:00
heinrich5991 4301ffab58 Give tests their own playground IStorage
Also add a function to clean it up after the test.
2021-05-14 01:00:41 +02:00
heinrich5991 fb27b83d79 Add function to remove directories
Add tests. Unify behavior of `fs_remove` across operating systems to
only remove files, not directories. Previously on Linux, it would also
delete directories.
2021-05-14 01:00:41 +02:00
heinrich5991 436e202cbd Add client-side HTTP server info
Summary
=======

The idea of this is that clients will not have to ping each server for
server infos which takes long, leaks the client's IP address even to
servers the user does not join and is a DoS vector of the game servers
for attackers.

For the Internet, DDNet and KoG tab, the server list is entirely fetched
from the master server, filtering out servers that don't belong into the
list.

The favorites tab is also supposed to work that way, except for servers
that are marked as "also ping this server if it's not in the master
server list".

The LAN tab continues to broadcast the server info packet to find
servers in the LAN.

How does it work?
=================

The client ships with a list of master server list URLs. On first start,
the client checks which of these work and selects the fastest one.
Querying the server list is a HTTP GET request on that URL. The
response is a JSON document that contains server infos, server addresses
as URLs and an approximate location.

It can also contain a legacy server list which is a list of bare IP
addresses similar to the functionality the old master servers provided
via UDP. This allows us to backtrack on the larger update if it won't
work out.

Lost functionality
==================

(also known as user-visible changes)

Since the client doesn't ping each server in the list anymore, it has no
way of knowing its latency to the servers.

This is alleviated a bit by providing an approximate location for each
server (continent) so the client only has to know its own location for
approximating pings.
2021-05-14 01:00:39 +02:00
heinrich5991 11adc8c1ff Make it possible to run jobs in the current thread 2021-05-13 03:15:18 +02:00
heinrich5991 782c826381 Add secure_rand_below function
It works by masking the numbers and the using rejection sampling to
ensure a uniform generation.
2021-05-12 17:02:02 +02:00
bors[bot] 1d0253aa67
Merge #3811
3811: Add Intel as vendor to the block list on windows r=def- a=Jupeyy

I also added, that the warning doesnt require to be displayed, as it currently won't help anyway to update the driver.

Should set all Intel users to OGL 2.0 default, they can ofc still manually change the setting as they want

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
2021-05-07 07:52:57 +00:00
def 6465e482a1 Add unit test for empty range 2021-05-06 15:39:34 +02:00
Jupeyy a0fdacf54f make tests work 2021-05-06 13:10:39 +02:00
heinrich5991 b2a54dc7f8 Compress IPv6 string representations according to RFC5952
https://tools.ietf.org/html/rfc5952#section-4

Also add some tests.
2021-05-05 18:22:52 +02:00
heinrich5991 8d6b62d8f8 Fix parsing an IPv6 address without port
The port in the NETADDR struct was left uninitialized.

Add some tests to ensure behavior.

CC #3774 #3775
2021-04-17 16:05:39 +02:00
bors[bot] 14e70506e1
Merge #3535
3535: Fix a possible race in load code  r=def- a=heinrich5991

Previously, a save could possibly be loaded twice given enough latency
discrepancy between servers. The server only verified that it deleted
*some* save with the given password, not *the* save it is trying to
load. This is fixed by also checking the SaveID column that is random
and globally unique (except for the old NULLs). Since users can't create
new saves with NULL SaveID, these pose no problem.

Also change the default UUID for saves without save ID to something
nonzero, so we can't accidentally hit it due to a bug.

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [x] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2021-01-23 10:14:32 +00:00
heinrich5991 3539f2b183 Allow ParseUuid to report errors and add tests 2021-01-23 01:21:20 +01:00
def 281492c0fa Fix memory leak in Thread.Lock unit test 2021-01-22 19:18:25 +01:00
def a99f4f15b6 Add str_utf8_truncate test for size 0 2021-01-22 19:18:11 +01:00
bors[bot] 40a36c2dfc
Merge #3377 #3487
3377: Add Thread Safety Analysis r=heinrich5991 a=def-

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


3487: Fix centisecs rounding in str_time_float r=heinrich5991 a=def-

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
2021-01-10 15:00:19 +00:00
Alexander Akulich c2f276cee1 Port CConfig API from the upstream (0.7.5)
The old (g_Config) API is kept to not break the stuff.

See commits:
    de5859b371
    78076761eb
2021-01-10 17:10:19 +03:00
def 7fa331a5e9 Fix centisecs rounding in str_time_float 2021-01-08 11:22:21 +01:00
heinrich5991 490a436ee6 Remove failing blocklist_driver tests
These were tests that fail when the blocklist changes.
2020-12-08 10:24:22 +01:00
def d04f2cf962 blocklist_driver unit test: also check gl version 2020-11-07 19:56:21 +01:00
Jupeyy 81a11532c5 Track the driver state 2020-11-07 07:01:12 +01:00
def 3b90f97aa5 Pull out blocklist_driver.cpp and unit test it 2020-11-06 19:00:14 +01:00
Zwelf 5914dbb8fa Fix UUID in test case comment for teehistorian-ddnetver-old@ddnet.tw 2020-11-03 23:00:39 +01:00
def 8dfcd67fe6 Add str_time/str_time_float
Handles centisecs < 0

Uses int64, otherwise we're limited to ~260 days
2020-10-18 23:44:47 +02:00
heinrich5991 6ff53358d3 Remove code for CRC in most places, except where needed for net compat
This should path the way to remove it altogether in the future.
2020-10-14 17:08:58 +02:00
def 3be8a592e5 Run clang-format
Purely automatic change. In case of conflict with this change, apply the
other change and rerun the formatting to restore it:

$ python scripts/fix_style.py
2020-09-26 21:50:15 +02:00
def 0bac9f0de8 Manual preparation for cleaner clang-format
Also include what you use explicitly
2020-09-26 21:41:01 +02:00
bors[bot] e3cfb23f28
Merge #2742 #2745
2742: Add str_utf8_copy that trim broken utf8 sequence at the end. r=heinrich5991 a=TsFreddie

Currently this replaces `str_copy` text input and clipboard paste in chat. Many places may need the same treatments, like steam names.

![image](https://user-images.githubusercontent.com/3797859/92263741-08b8e080-eed5-11ea-84a5-b7f070ded260.png)

Test string:
abcd今天是个好日子心想的事儿都能成今天是个好日子打开了家门咱迎春风今天是个好日子心想的事儿都能成今天是个好日子打开了家门咱迎春风今天是个好日子心想的事儿都能成今天是个好日子打

2745: Update mapres by mind r=heinrich5991 a=def-

Adapted from 0.7 for new renderer. Not sure if this makes sense :D

Co-authored-by: TsFreddie <tsfreddiewang@gmail.com>
Co-authored-by: def <dennis@felsin9.de>
2020-09-06 23:12:04 +00:00
TsFreddie 05c199e2aa I can't count 2020-09-07 00:03:40 +01:00
TsFreddie e48596dc6c Add test cases 2020-09-06 23:57:21 +01:00
Jupeyy aed4293040 Prevent NULL pointer in mem_copy (fixes #2753) 2020-09-06 18:32:56 +02:00
heinrich5991 5b669bcb32 Only send valid UTF-8 over the network 2020-09-03 18:50:23 +02:00
def e2fde4d730 Fix utf8 handling in str_truncate (fixes #2533)
and rename to str_utf8_truncate since it's only used for utf8 strings
2020-08-02 18:32:42 +02:00
heinrich5991 9ed54440cb Add some tests for the bezier stuff 2020-07-02 11:07:30 +02:00
Zwelf 7b32a8330d Add save/load teehistorian test 2020-06-26 00:01:12 +02:00
heinrich5991 0db5c51ed9 Add a simple CSV writer for Python's "excel" csv dialect 2020-06-23 09:11:59 +02:00
heinrich5991 e294da41ba teehistorian: Track whether clients join via the 0.7 protocol 2020-06-19 22:06:39 +02:00
bors[bot] 92fc95d742
Merge #2202
2202: Send DDNet version early in the connection process r=Learath2 a=heinrich5991

This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
2020-05-27 17:49:31 +00:00
heinrich5991 c9c7f947b5 Use the PCG-XSH-RR PRNG instead
This came from a long discussion comparing PCG-* against xoroshiro*. Do
not generate integers without bias because it doesn't affect us very
much and it is easier to reimplement with modulo.
2020-05-26 10:59:49 +02:00
heinrich5991 2692f3c758 Use a consistent PRNG on all platforms 2020-05-25 15:19:29 +02:00
heinrich5991 7f14b4b2bb Add glibc's PRNG
Based on a description on https://www.mscs.dal.ca/~selinger/random/
(retrieved 2020-05-25).
2020-05-25 15:19:25 +02:00
heinrich5991 0d7872c79e Send DDNet version early in the connection process
This gets rid of the problem that we don't know whether we should send
full snapshots to clients because they haven't told us about them being
DDNet yet.
2020-05-22 17:58:41 +02:00
ChillerDragon 4a6a85124a Remove some unused includes 2019-12-14 10:20:42 +01:00
Learath 0d39eb128d Use unsigned integers for colors 2019-05-15 18:05:19 +02:00
Dennis Felsing 5e356b5327
Merge pull request #1692 from def-/pr-news
Render news without STL functions
2019-05-10 14:09:44 +02:00
def 51385100cd Make Color.HRHConv test runtime more reasonable
Previous execution time: 650 ms / 661 ms total (98%)
Now:                       3 ms /  15 ms total (20%)
2019-05-09 21:55:34 +02:00
def e1c9033300 Render news without STL functions (fixes #1693) 2019-05-09 21:54:56 +02:00
bors[bot] a2f44299e0 Merge #1678
1678: Handle colors in console r=def- a=Learath2

DEPENDS: #1654 

A better way to fix #1581 possibly deprecates #1597 

Co-authored-by: Learath <learath2@gmail.com>
2019-04-30 19:39:56 +00:00
bors[bot] d8964ceedb Merge #1654 #1685
1654: Try working on colors a bit r=def- a=Learath2

There were color functions everywhere, I tried cleaning it up a little. I still couldn't get the roundtrip from Hsl to Rgb to be exactly the same, but I think this is the best possible.

1685: Work on compound binds r=def- a=Learath2

Closes #1417 

Co-authored-by: Learath <learath2@gmail.com>
2019-04-29 15:56:16 +00:00
Learath 6b815b2375 Work on compound binds 2019-04-28 16:32:49 +03:00
Learath 1b668916f2 Fix the test, fix small bug 2019-04-26 21:01:41 +03:00
Learath 93265dbb9c Please MSVC 2019-04-25 21:09:32 +03:00
Learath 0f781df1dd Try handling colors in console 2019-04-25 14:48:53 +03:00
Learath 5e5def314f Add tests 2019-04-24 23:53:38 +03:00
Dennis Felsing 00c87c121a str_num_copy -> str_truncate, as in Vanilla 0.7 2019-04-18 10:25:01 +02:00
Learath 843dc29a88 Names can include quotes :/ 2019-04-16 02:39:22 +02:00
heinrich5991 e44b1ca986 Use OpenSSL md5 if it is available
Fixes #1582.
2019-04-06 02:56:29 +02:00
yangfl ee104428bb Fix negative numbers in char
On some architectures char can be unsigned, which makes g++
very unhappy.

  error: narrowing conversion of '-128' from 'int' to 'char' inside { }
2019-04-02 23:19:20 +08:00
def d9804f5142 str_format: always return length of written string
Quoting the man page of vsnprintf:

RETURN VALUE
  Upon successful return, these functions  return  the  number  of  characters  printed
  (excluding the null byte used to end output to strings).

  The functions snprintf() and vsnprintf() do not write more than size bytes (including
  the terminating null byte ('\0')).  If the output was truncated due  to  this  limit,
  then  the  return  value  is the number of characters (excluding the terminating null
  byte) which would have been written to the final string  if  enough  space  had  been
  available.  Thus, a return value of size or more means that the output was truncated.
  (See also below under NOTES.)

  If an output error is encountered, a negative value is returned.

[...]

  The glibc implementation of the functions snprintf() and vsnprintf() conforms to  the
  C99  standard,  that  is, behaves as described above, since glibc version 2.1.  Until
  glibc 2.0.6, they would return -1 when the output was truncated.
2019-03-21 13:39:25 +01:00
def 1e4890c499 More error checking in system.c (fixes #1317) 2019-03-19 23:16:29 +01:00
heinrich5991 8b3f0246a9 Use EXPECT_* rather than ASSERT_* in tests
`EXPECT_*` allows the test to continue even in the case of failure. Use
this where it makes sense to continue.
2019-03-12 02:06:54 +01:00
Dennis Felsing b8c256b602
Merge pull request #1467 from 12pm/nameban_exact
Add exact name ban option
2019-03-11 22:50:39 +01:00
12pm 6086f46bed Add substring tests 2019-03-11 15:00:51 +01:00
bors[bot] d8e8a21a30 Merge #1469
1469: Don't use strtok. Close #1468 r=heinrich5991 a=Learath2

^

Co-authored-by: Learath <learath2@gmail.com>
2019-03-11 11:56:26 +00:00
Learath f6c15f1de0 Style 2019-03-11 14:54:31 +03:00
Learath 9713f6c2cd Improve interface to function 2019-03-11 14:39:54 +03:00
Learath c4af290df5 Don't use strtok. Close #1468 2019-03-05 12:46:29 +03:00
12pm 572e9532ee Fix tests 2019-03-03 19:02:42 +01:00
Learath 548e9969b2 Add colors for authed players. Deprecates #1299 2019-03-02 13:50:33 +03:00
Learath a46c31f356 Add a couple tests, fix #1457 2019-02-13 15:14:46 +01:00
Learath 867facfffc Forgot str_tokenize is not used now 2019-02-13 15:13:27 +01:00
Dennis Felsing 698a3f1c5a
Merge pull request #1443 from ChillerDragon/AutobanKnownBots
Add autoban depending on client version
2019-02-13 12:04:51 +01:00
Learath 5d99746cc1 Add str_tokenize and str_in_list 2019-02-11 18:40:40 +01:00
12pm 74992d9bd7 Fix tests 2019-02-10 19:13:55 +01:00
def faa3cc195d UTF8 nocase compare & use for chat TAB completion
- As suggested by Arseniy Zarche
- Also updated confusables to Unicode 12
2019-01-09 08:31:03 +01:00
Dennis Felsing 5c18d6c481 Remove /modhelp (fixes #1401) 2018-12-12 10:05:44 +01:00