The KS test measures the maximum vertical gap D between the empirical CDF of your sample and a theoretical CDF. Under the null hypothesis, D·√n converges to the Kolmogorov distribution — giving a p-value without any parametric assumptions about the distribution shape.