mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 07:39:58 +00:00
Add test to make sure sanitizers really work when expected (#10838)
This commit is contained in:
@@ -64,6 +64,8 @@ VERSIONS_COMBINATIONS = (
|
|||||||
# If it is not set or set to a value not equal to "false", LFC is enabled by default.
|
# If it is not set or set to a value not equal to "false", LFC is enabled by default.
|
||||||
USE_LFC = os.environ.get("USE_LFC") != "false"
|
USE_LFC = os.environ.get("USE_LFC") != "false"
|
||||||
|
|
||||||
|
WITH_SANITIZERS = os.environ.get("SANITIZERS") == "enabled"
|
||||||
|
|
||||||
|
|
||||||
def subprocess_capture(
|
def subprocess_capture(
|
||||||
capture_dir: Path,
|
capture_dir: Path,
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from fixtures.neon_fixtures import NeonEnvBuilder
|
from fixtures.neon_fixtures import NeonEnvBuilder
|
||||||
|
from fixtures.pg_version import PgVersion
|
||||||
|
from fixtures.utils import WITH_SANITIZERS, run_only_on_postgres
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -23,3 +25,20 @@ def test_endpoint_crash(neon_env_builder: NeonEnvBuilder, sql_func: str):
|
|||||||
endpoint.safe_psql("CREATE EXTENSION neon_test_utils;")
|
endpoint.safe_psql("CREATE EXTENSION neon_test_utils;")
|
||||||
with pytest.raises(Exception, match="This probably means the server terminated abnormally"):
|
with pytest.raises(Exception, match="This probably means the server terminated abnormally"):
|
||||||
endpoint.safe_psql(f"SELECT {sql_func}();")
|
endpoint.safe_psql(f"SELECT {sql_func}();")
|
||||||
|
|
||||||
|
|
||||||
|
@run_only_on_postgres([PgVersion.V17], "Currently, build vith sanitizers is possible with v17 only")
|
||||||
|
def test_sanitizers(neon_env_builder: NeonEnvBuilder):
|
||||||
|
"""
|
||||||
|
Test that undefined behavior leads to endpoint abort with sanitizers enabled
|
||||||
|
"""
|
||||||
|
env = neon_env_builder.init_start()
|
||||||
|
env.create_branch("test_ubsan")
|
||||||
|
endpoint = env.endpoints.create_start("test_ubsan")
|
||||||
|
|
||||||
|
# Test case based on https://www.postgresql.org/message-id/17167-028026e4ca333817@postgresql.org
|
||||||
|
if not WITH_SANITIZERS:
|
||||||
|
endpoint.safe_psql("SELECT 1::int4 << 128")
|
||||||
|
else:
|
||||||
|
with pytest.raises(Exception, match="This probably means the server terminated abnormally"):
|
||||||
|
endpoint.safe_psql("SELECT 1::int4 << 128")
|
||||||
|
|||||||
Reference in New Issue
Block a user